Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top