From owner-freebsd-questions Mon Mar 3 10:53:45 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 568CC37B401 for ; Mon, 3 Mar 2003 10:53:43 -0800 (PST) Received: from dialups-247.anchorage.mtaonline.net (ai1.anchorage.mtaonline.net [12.17.140.247]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9D4C643FAF for ; Mon, 3 Mar 2003 10:53:37 -0800 (PST) (envelope-from abc@dialups-247.anchorage.mtaonline.net) Received: from en26.dialups-247.anchorage.mtaonline.net (root@printer [192.168.0.26]) by dialups-247.anchorage.mtaonline.net (8.12.6/8.12.6) with ESMTP id h1SJEe2e000290; Fri, 28 Feb 2003 10:14:40 -0900 (AKST) (envelope-from abc@dialups-247.anchorage.mtaonline.net) Received: (from abc@localhost) by en26.dialups-247.anchorage.mtaonline.net (8.12.6/8.12.6) id h1SIWbSp046258; Fri, 28 Feb 2003 18:32:37 GMT (envelope-from abc@[12.17.140.247]) Date: Fri, 28 Feb 2003 18:32:37 GMT From: abc@dialups-247.anchorage.mtaonline.net Message-Id: <200302281832.h1SIWbSp046258@en26.dialups-247.anchorage.mtaonline.net> X-Authentication-Warning: en26.dialups-247.anchorage.mtaonline.net: abc set sender to abc@[12.17.140.247] using -f Subject: Re: #!/bin/sh & execve X-Mailer: Umail v2.9.2 To: "freebsd-questions" To: Giorgos Keramidas Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > the method used by FBSD 2.2.7 seems the most sane to me, > > where execve's argv[] is loaded by each whitespace > > seperated element after the shebang, > > then by command line options. > > > > 1. it is flexible. > > 2. it functions intuitively. > > 3. i don't think it breaks less flexible methods. > > It also suffers from problems with arguments that are meant to include > spaces, like: > > #!/bin/sh "hello world" "foo bar" > > Without a fully functional sh(1)-like parser, any solution that does > magic with argv[] is incomplete :-( Apologies for a delayed response. This concerned how to load execve()'s argv[] array when parsing the 'shebang' line of a script, ie: whether to pass everything after '#!/interpeter' 1. as one string into execve()'s argv[] array, as some systems do, or 2. as individual arguments, as exist after #!/interpreter, separated by whitespace. Bug report 16383 showed the variance in the various UNIX's of how this is done. Orginal SysV specs say to load '1 argument' only after #!/interpreter, leaving it ambiguous as to whether the '1 argument' is the 1st whitespace separated argument, or whether it is everything after #!/interpreter as one string. Posix and SUSv3 don't say anything about how to load execve()'s argv[] array after #!/interpreter, and seem to leave it to "whatever is the most intelligent way". I suggested it made more sense as FBSD 2.2.7 used to do it, where execve()'s argv[] array was loaded contiguously with whitespace separated elements, so one could use constructs such as "#!/bin/sh /script-preprocessor options", and to allow "#!/interpreter opt1 opt2" and "#!/interpreter opt1 arg1" type constructs, things that intuitively work as one would expect on a command line, since there didn't appear to be any penalty for allowing this flexibility. A plausible argument was given in response: > #!/bin/sh "hello world" "foo bar" I repond as follows: that's something only a Windoze user would think of doing! :) Unix users don't put whitespace in filenames, nor would they create options to programs that contain whitespace. Also, to load: '"hello world" "foo bar"' as one string, breaks it's purpose anyway. it is a bizarre example that has little practical value, and can be easily compensated for by getting rid of whitespace in a filename, in the bizarre case where it may exist as such. Finally, to be slightly extreme with a tiny performance penalty, a beginning and ending quote in a string could be check for and respected by execve()'s code that fills argv[]. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message