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

Eli Barzilay eli at barzilay.org
Wed Nov 15 15:38:14 EST 2006


On Nov 15, Per Bothner wrote:
> Eli Barzilay wrote:
> > On Nov 15, Per Bothner wrote:
> >> When you need to pass extra options you can use Kawa's
> >> "--script2 FILENAME" which run the named file as a source file,
> >> skipping the first two lines.  This allows:
> >>
> >> #!/bin/sh
> >> exec kawa --various --options --script2 "$0" "$@"
> >> (define (foo) ...)
> >> (foo ...)
> > 
> > An easier solution is to ise #|...|#
> > 
> >   #!/bin/sh
> >   #|
> >   exec whatever "$0" "$@"
> >   |#
> >   ...
> 
> You're right.  It's so long ago that I implemented --script2 that
> I don't remember what my reason was for preferring that solution
> over yours - or whether I just didn't think of it.
> 
> One disadvantage of your solution is that it is a little uglier,
> but that can be fixed if we make #!/ require an ending delimiter:
> 
> #!/bin/sh
> exec whatever "$0" "$@"
> !#
> scheme code

Well, mine is uglier in the above, but prettier in the below.

> or:
> 
> #!/usr/bin/env scheme
> !#
> scheme code
> 
> The closing delimiter could be another #!, which looks nicer:
> 
> #!/usr/bin/env scheme
> #!
> scheme code

(That's asking for trouble...)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!



More information about the r6rs-discuss mailing list