Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-WebMail-UserID: pjacklam AT online DOT no Date: Fri, 22 Feb 2002 14:26:43 +0100 From: pjacklam To: cygwin AT cygwin DOT com X-EXP32-SerialNo: 50000140 Subject: Re: /usr/bin/env - Incorrect parsing of #! line? Something that works! Message-ID: <3C77FCA6@epostleser.online.no> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: InterChange (Hydra) SMTP v3.62 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 AT online DOT 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/