/usr/bin/env - Incorrect parsing of #! line? Something that works!

pjacklam pjacklam@online.no
Fri Feb 22 06:15:00 GMT 2002


I did, finally, find two solutions which work on both
Cygwin and Solaris, which is pretty much all I need.
In case someone is interested, here are the solutions.

Alternative 1
=============
This forces the script to be interpreted by "sh".
        :
        eval 'exec perl -wS $0 ${1+"$@"}'
          if 0;

I am not sure why replacing ":" with "#!/bin/sh" doesn't
work though, but doing so gives on Solaris
"-wS: bad option(s)" and on Cygwin: "Illegal option -w".

Alternative 2
=============
This checks to see what kind of syntax the running shell
accepts (Bourne shell style or C shell style) and then
calls perl in a way appropriate for the running shell.

        eval '(exit $?0)' && eval 'exec perl -wS $0 ${1+"$@"}'
        & eval 'exec perl -wS $0 $argv:q'
          if 0;

Peter

-- 
Peter J. Acklam - pjacklam@online.no - http://home.online.no/~pjacklam


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list