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

From: Per Bothner <per>
Date: Wed Nov 15 15:32:52 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" "$_at_"
>> (define (foo) ...)
>> (foo ...)
>
> An easier solution is to ise #|...|#
>
> #!/bin/sh
> #|
> exec whatever "$0" "$_at_"
> |#
> ...

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" "$_at_"
!#
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/
Received on Wed Nov 15 2006 - 15:33:47 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:00 UTC