This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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/


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