Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Tue, 5 Oct 2004 20:34:49 -0400
From: Christopher Faylor <cgf-no-personal-reply-please@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Shell script ignores $PATH?!
Message-ID: <20041006003449.GA20922@trixie.casa.cgf.cx>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <41628485.1BC86580@dessent.net> <20041005234856.9AEE684C3C@pessard.research.canon.com.au>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20041005234856.9AEE684C3C@pessard.research.canon.com.au>
User-Agent: Mutt/1.4.1i

On Wed, Oct 06, 2004 at 09:48:56AM +1000, luke.kendall@cisra.canon.com.au wrote:
>On  5 Oct, Brian Dessent wrote:
>>If you want to specify what shell is used to run a script you either
>>need to specify it in the shebang of the script (#!/path/to/shell) or
>>you need to start that shell explicitly (/path/to/shell
>>/path/to/script).  If you try to execute a script with no shebang then
>>the behavoir is going to be system-dependent.  On cygwin that means
>>defaulting to /bin/sh, as you can see from spawn.cc:spawn_guts()
>>   
>>        if (buf[0] != '#' || buf[1] != '!') 
>>          { 
>>            pgm = (char *) "/bin/sh"; 
>>            arg1 = NULL; 
>>          } 
>
>Thanks, Brian.
>
>It'd be nicer if it instead looked for sh in PATH,

Nicer for you.  Not so nice for someone who has a sh.exe in their path
which is not cygwin-aware or is not actually a shell at all.

><rant>
>BTW, I've wondered for many years why the #! notation doesn't allow a
>pathless program name, to mean "look it up in PATH" in the normal way.

#!/usr/bin/env perl

It's a standard idiom.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

