[r6rs-discuss] [Formal] "#! /usr/bin/env" is not "portable." It's Unix-specific.

Jens Axel Søgaard jensaxel at soegaard.net
Wed Nov 15 09:51:04 EST 2006


Nils M Holm skrev:
 > On Wed, Nov 15, 2006 at 02:11:24PM +0100, Jens Axel Søgaard wrote:
 >> Nils M Holm skrev:
 >>> On Tue, Nov 14, 2006 at 10:04:40PM -0500, Peter Gavin wrote:
 >>>> In addition, I would drop the requirement that the first line be
 >>>> ignored.  That wouldn't be needed were #! a comment indicator.
 >>> Ignoring the first line would open the door to a lot of bad
 >>> surprises for people who start learning Scheme.
 >> In practise, implementations will probably only ignore the
 >> first line, if it starts with a #!
 >
 > I would be happy if this was so, but in <7.1.1> R5.91RS states that
 >
 > "Implementations are required to ignore the first line, however,
 >  even if it is not the above."
 > ("The above" being "#! /usr/bin/env scheme-script".)

In version r6rs_91_4 it says:

     Implementations are required to ignore the first line of
     a script, however, even if it is not the above.

If the file doesn't start with

    #! <yada yada>

it isn't a script, and an implementation can do what ever it wish
(but is non-portable of course).

 >>> Plus it would make all one-liners two-liners, which I think
 >>> would be rather inelegant.
 >> If we don't treat the first line specially, then all one-liners
 >> become two-file scripts in Unix.
 >
 > I am not against #! in general, I just do not understand why
 > we have to treat the first line in a special way. Why is it not
 > sufficient to make #! a comment to the end of line?

It is sufficient, but is it neccesary?

 > This would still allow you to run
 >
 > % echo "(+ 1 2 3)" | my-interpreter
 >
 > while enabling Scheme programs to run as scripts at the same time.
 >
 > What am I missing?

I am not sure, but I think some Scheme implementations use the
syntax #!name  for other stuff (keywords, optionals? - I
can't remember exactly)

-- 
Jens Axel Søgaard




More information about the r6rs-discuss mailing list