From owner-freebsd-current@FreeBSD.ORG Wed Sep 29 11:47:09 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1501416A4CE for ; Wed, 29 Sep 2004 11:47:09 +0000 (GMT) Received: from ptcnat.era.pl (ptcnat.era.pl [213.158.197.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id C1A4B43D41 for ; Wed, 29 Sep 2004 11:47:08 +0000 (GMT) (envelope-from zaks@era.pl) Received: by localhost (Postfix, from userid 1001) id 0409B11652; Wed, 29 Sep 2004 13:47:06 +0200 (CEST) From: =?iso-8859-2?q?S=B3awek_=AFak?= To: Ceri Davies References: <861xgm5ltz.fsf@thirst.unx.era.pl> <20040928194853.GT2493@submonkey.net> Date: Wed, 29 Sep 2004 13:47:06 +0200 In-Reply-To: <20040928194853.GT2493@submonkey.net> (Ceri Davies's message of "Tue, 28 Sep 2004 20:48:53 +0100") Message-ID: <86k6ud2t6t.fsf@thirst.unx.era.pl> User-Agent: Gnus/5.110003 (No Gnus v0.3) XEmacs/21.4 (Reasonable Discussion, berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: freebsd-current@freebsd.org Subject: Re: Bug in #! processing X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Sep 2004 11:47:09 -0000 Ceri Davies writes: > On Tue, Sep 28, 2004 at 07:45:28PM +0200, S?awek ?ak wrote: >> Hi, >> >> It seems that there is a long standing bug in processing of command-line >> options for scripts and such. Take following files: >> [...] >> On FreeBSD 5.x: >> >> thirst(1790)% ./tst.sh >> Main.c test >> ./main >> - >> ./tst.sh >> >> On Solaris: >> >> sb8:root> ./tst.sh >> Main.c test >> ./main >> -#! >> ./tst.sh >> >> sb8:root> uname -a >> SunOS sb8 5.8 Generic_108528-21 sun4u sparc SUNW,UltraAX-i2 > > [snip Tru64 and AIX] > >> Any takers? > > It's easy enough to fix this case, but Solaris looks buggy in other > areas You should speel buggy as 'POSIX' in this case I guess. > (I do not have any other systems to hand): > > FreeBSD 4.10-STABLE: > > $ cat tst.sh > #!./main -f -o -#! > print ok > $ ./tst.sh > Main.c test > ./main > -f > -o > - > ./tst.sh Well, it is consistent with FreeBSD 5.x in this respect. Discards all after second #! when passing arguments to the interpretter. > Solaris 9: > > $ ./tst.sh > Main.c test > ./main > -f > ./tst.sh This behavior is mandated by POSIX which, as I reckon, allows passing of only the first argument to the interpreter. It is confirmed by other supposedly compliant systems. I've checked before AIX 5.2, Solaris 8/9. Two raisins in the pie are Tru64 5.1B and HP-UX 11, which return some erm, strange results. For such script: #!./main 1 2 3 -#! print ok You get: Main.c test ./main 1 2 3 -#! ./tst.sh Thus it seems that the systems squeeze all arguments in one and pass it that way to our handsome interpreter. Nevertheless both Tru64 and HPUX are dying and we got to move on with our lives. The behavior I'd like to have, and which seems correct is not bothering with second, 3rd and so on occurence of #! in the first line of script. Feasible? I guess so. The only commercial product on my systems uses -#! switch on all platforms as a script file mark. I don't see any explanation for current behavior therefore I'm reporting it. /S