From owner-freebsd-bugs Tue Feb 19 8:30: 9 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id E272337B402 for ; Tue, 19 Feb 2002 08:30:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g1JGU1Q33003; Tue, 19 Feb 2002 08:30:01 -0800 (PST) (envelope-from gnats) Date: Tue, 19 Feb 2002 08:30:01 -0800 (PST) Message-Id: <200202191630.g1JGU1Q33003@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Ahmon Dancy Subject: Re: bin/16393: /bin/sh doesn't strip comments on shebang line Reply-To: Ahmon Dancy Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/16393; it has been noted by GNATS. From: Ahmon Dancy To: freebsd-gnats-submit@freebsd.org Cc: Subject: Re: bin/16393: /bin/sh doesn't strip comments on shebang line Date: Tue, 19 Feb 2002 08:26:26 -0800 We ran into a problem today related to this issue (we used the # character as switch to our program). I did some studies on various other operating systems and FreeBSD hosts that have the modifications suggested by bin/16393 fall short. Here are the results of my study: Given a file called '/tmp/x2' with shebang line: #!/tmp/interp -a -b -c #dee eee If /tmp/x2 is exec'd, the operating system runs /tmp/interp w/ the following arguments: Solaris 8: args: "/tmp/interp" "-a" "/tmp/x2" Tru64 4.0: args: "interp" "-a -b -c #dee eee" "/tmp/x2" FreeBSD 2.2.7: args: "/tmp/interp" "-a" "-b" "-c" "#dee" "eee" "/tmp/x2" FreeBSD 4.0: args: "/tmp/interp" "-a" "-b" "-c" "/tmp/x2" Linux 2.4.12: args: "/tmp/interp" "-a -b -c #dee eee" "/tmp/x2" Linux 2.2.19: args: "interp" "-a -b -c #dee eee" "/tmp/x2" Irix 6.5: args: "/tmp/interp" "-a -b -c #dee eee" "/tmp/x2" HPUX 11.00: args: "/tmp/x2" "-a -b -c #dee eee" "/tmp/x2" AIX 4.3: args: "interp" "-a -b -c #dee eee" "/tmp/x2" Mac OX X: args: "interp" "-a -b -c #dee eee" "/tmp/x2" The most common behavior is: argv[0]: full path of interpreter argv[1]: all remaining args, coalesced into one string argv[2]: The file file exec'd. FreeBSD's behavior is way out there. No other system treats "#" in any special way. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message