This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: /usr/bin/env and guile


> 
> Michael Vanier <mvanier@bbb.caltech.edu> cited below with "MV" writes:
> 
> MV> Is it possible to start up a guile script with /usr/bin/env?  I tried this
> MV> but it didn't work on my system:
> 
> MV> #!/usr/bin/env guile -s
> MV> !#
> 
> MV> ...
> 
> MV> This prints out an error message, apparently because guile thinks that the
> MV> name of the file is a switch.  Is there a workaround?  Is this a bug or
> MV> just a missing feature?  It's certainly easier to use env than to type a
> MV> long filename (not to mention more portable). 
> 
> It is highly unportable if you assume that an OS supports more than one
> argument with the `#!' feature.  The only system which does it is AFAIK
> FreeBSD, some systems pass only the first argument, while other systems
> pass the remaining line after the first space as the first argument to
> the program.  The only thing which would help Guile are hacks like Tcl's
> 
> 	#! /bin/sh
> 	#\
> 	exec wish $0 ${1+"$@"}
> 

Well, this is on Solaris, and I tried the same approach on perl and python
for comparison.  Interestingly, python ignored the extra arguments (as does
guile) but perl somehow figured out a way to use them even with
/usr/bin/env.  I don't know if this generalizes to other OSs.  The other
difference with perl and python is that you don't need the extra arguments,
whereas in guile you do.  


> BTW, do not write `#!/', always write `#! /' (including the whitespace).
> There are systems out there treating the first 4 bytes of an executable
> as a magic binary number.
> 
> -- 
> Ralph
> 

Right.  I normally do that anyway.

Mike