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

Per Bothner per at bothner.com
Wed Nov 15 15:33:47 EST 2006


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

or:

#!/usr/bin/env scheme
!#
scheme code

The closing delimiter could be another #!, which looks nicer:

#!/usr/bin/env scheme
#!
scheme code
-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/



More information about the r6rs-discuss mailing list