From owner-freebsd-questions Sat Feb 8 13:58:31 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 5473F37B401 for ; Sat, 8 Feb 2003 13:58:30 -0800 (PST) Received: from groggy.anc.acsalaska.net (groggy.anc.acsalaska.net [208.151.119.232]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0A61243F3F for ; Sat, 8 Feb 2003 13:58:27 -0800 (PST) (envelope-from abc@anchorageinternet.org) Received: from en26.groggy.anc.acsalaska.net (root@printer [192.168.0.26]) by groggy.anc.acsalaska.net (8.12.6/8.12.6) with ESMTP id h18Lw87X017064 for ; Sat, 8 Feb 2003 12:58:08 -0900 (AKST) (envelope-from abc@anchorageinternet.org) Received: (from abc@localhost) by en26.groggy.anc.acsalaska.net (8.12.6/8.12.6) id h18LwbM9034701 for "freebsd-questions" ; Sat, 8 Feb 2003 21:58:37 GMT (envelope-from abc@anchorageinternet.org) Date: Sat, 8 Feb 2003 21:58:37 GMT From: abc@anchorageinternet.org Message-Id: <200302082158.h18LwbM9034701@en26.groggy.anc.acsalaska.net> X-Authentication-Warning: en26.groggy.anc.acsalaska.net: abc set sender to abc@anchorageinternet.org using -f Subject: Re: #!/bin/sh & execve X-Mailer: Umail v2.9.2 To: "freebsd-questions" 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 this does seem to be an ambiguous area. it seems more sane to allow arguments to a script given to an interpreter on the shebang line, passing everything after "#!/interpreter [arg]" off for "eval" or "sh -c" type parsing. i don't know how it breaks anything to load execve's argv[] with everything after the shebang, followed by command line options/args. but it sure muddies the water if you don't. otherwise there is a can of worms unnecessarily: #!/bin/sh -x this is obviously ok. #!/bin/sh -vx this is obviously ok too. #!/bin/sh -c"string" this is currently not ok, but why shouldn't it be? #!/bin/sh -c "string" this is currently not ok, but why shouldn't it be? #!/bin/sh script this is obviously ok. #!/bin/sh -n script this is currently not ok, but why shouldn't it be? #!/bin/sh script 1 2 this is ok with FBSD and RH Linux, but not ok in a few implementations, but why shouldn't it be? it seems that only a minority of execve() man pages / implementations are preventing the sane solution ... > The only thing I can find in IEEE Std 1003.1-2001 (aka SUSv3) is > > "If the first line of a file of shell commands starts with the > characters "#!", the results are unspecified." > > which would indicate that there is no "proper" way of doing this. You > may also want to have a look at bin/16393; at the bottom is a list of > how some unices handle the situation. Your best bet at trying to be > portable is to use at most one argument, no whitespace and no "#". > > The PR: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message