|
|
Subscribe / Log in / New account

Wrong interpreter

Wrong interpreter

Posted Feb 19, 2019 15:08 UTC (Tue) by anton (subscriber, #25547)
In reply to: Wrong interpreter by rgmoore
Parent article: The case of the supersized shebang

Gforth treats #! as starting a comment line.

Why not reread the #! line and interpret it? Because treating it as a comment is simpler, by quite a lot. Consider a gforth script script that is invoked with

./script scriptarg1 scriptarg2
and starts with
#! /usr/bin/gforth gfortharg
Then the kernel constructs the following command line:
/usr/bin/gforth gfortharg ./script scriptarg1 scriptarg2
Note that gforth processes gfortharg before the rest of the command line. Then, when it sees ./script, and the #! at its start, it might start doing something about this line. But why, given that the kernel already does it nicely (well, in most cases at least)?

One advantage of doing your own processing is that one could have more than one argument on the #! line, as demonstrated in the Perl case, but for now the pain has not been big enough to go to these lengths.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds