From owner-freebsd-current@FreeBSD.ORG Thu Sep 30 11:59:51 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 3F27916A4CF for ; Thu, 30 Sep 2004 11:59:51 +0000 (GMT) Received: from ptcnat.era.pl (ptcnat.era.pl [213.158.197.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 66ABC43D4C for ; Thu, 30 Sep 2004 11:59:50 +0000 (GMT) (envelope-from zaks@era.pl) Received: by localhost (Postfix, from userid 1001) id 6F4F0117F4; Thu, 30 Sep 2004 13:59:48 +0200 (CEST) From: =?iso-8859-2?q?S=B3awek_=AFak?= To: Ceri Davies References: <861xgm5ltz.fsf@thirst.unx.era.pl> <20040928194853.GT2493@submonkey.net> <86k6ud2t6t.fsf@thirst.unx.era.pl> <20040929131136.GA2493@submonkey.net> Date: Thu, 30 Sep 2004 13:59:48 +0200 In-Reply-To: <20040929131136.GA2493@submonkey.net> (Ceri Davies's message of "Wed, 29 Sep 2004 14:11:37 +0100") Message-ID: <86mzz8x8zv.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: Thu, 30 Sep 2004 11:59:51 -0000 Ceri Davies writes: > On Wed, Sep 29, 2004 at 01:47:06PM +0200, S?awek ?ak wrote: [...] >> You should speel buggy as 'POSIX' in this case I guess. > You're actually guessing though, right? I can't find this in the > standard; if you know it's there then I'd appreciate a reference. No reference on this. Vague memories of brokedness only. [...] >> This behavior is mandated by POSIX which, as I reckon, allows passing of >> only the first argument to the interpreter. > > Are you guessing again? Affirmative. > I believe that the FreeBSD behaviour is closer to "correct" than > anything else we're seeing in this thread. I should be able to specify > > #!/usr/bin/perl -w -0 > > or whatever without having everything other than the first argument > ignored. Would be nice. I admit. I like the bahavior of FreeBSD besides special treatment of # on the first line after #!. Allowing for comments on the first line is a strange excuse. Have you ever seen a script commenting on the interpreter execution or had a need to do so? >> 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 > > Linux 2.4.20 does this too. That's as silly as can get. When called as: interpreter -a1 -a2 -a3 script the argument parsing done by interpreter must be different then when invoked via #! mechanics. Argh! >> 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. > > That seems wrong too. #! shouldn't be magic anywhere other than at the > beginning of a file. Do you think that -#! argument is magic? Why is it so? It's not magic and should be passed without exec(2) interference. >> I don't see any explanation for current >> behavior therefore I'm reporting it. > > The explanation is that we only process that line up to a '#' or > newline. Backing out revision 1.21 of sys/kern/imgact_shell.c is one > fix, or perhaps allowing a '#' character to be escaped. I'm not sure if > I see an overwhelming reason for either. I don't see a convincing use for comments on the first line of script. Hash is special already when treated as comment character. # is not a comment in any `scripting language'. It is a shell legacy and shouldn't be forced on the remaining universe. /S