Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix shebang with Gforth

I'm having trouble getting Gforth to run when I have a shebang at the top of the script, like:

#!/usr/bin/gforth
: pinoke ." I'm a real boy!!! "
pinoke

Unix appears to be launching gForth okay, but gForth itself chokes on the shebang line. I'm not sure how a word could be defined to cause Forth to interpret the shebang line differently (not to say it can't be done, but I'm just not sure how it would be).

I've considered using a script to feed the code file to gForth, but that can be rather awkward to do over and over. Is there a way to make gForth accept the shebang like other languages?

like image 290
beeflobill Avatar asked Dec 01 '25 14:12

beeflobill


1 Answers

You need a space between #! and /usr/bin/gforth.

See 13.7 Running Image Files (in the Gforth manual):

The sequence #! is used in two ways; firstly, it is recognised as a “magic sequence” by the operating system1 secondly it is treated as a comment character by Gforth. Because of the second usage, a space is required between #! and the path to the executable

like image 142
Lars Brinkhoff Avatar answered Dec 03 '25 07:12

Lars Brinkhoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!