Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jan 2000 18:37:59 -0800 (PST)
From:      ryand@amazon.com
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/16393: /bin/sh doesn't strip comments on shebang line
Message-ID:  <20000127023759.19A7214E20@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         16393
>Category:       bin
>Synopsis:       /bin/sh doesn't strip comments on shebang line
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 26 18:40:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Ryan Davis
>Release:        3.3-STABLE (with latest /bin/sh)
>Organization:
Amazon.com
>Environment:
FreeBSD qa-tools.amazon.com 3.3-STABLE FreeBSD 3.3-STABLE #0: Tue Jan 11 12:50:31 PST 2000     root@qa-tools.amazon.com:/usr/src/sys/compile/RWD_BSD_v3  i386

>Description:
Basically, if I follow the suggestions in the perl book to make 
portably executable scripts, I must use a shebang hack where the 
perl script starts being executed as a sh script. sh will pass it off 
to perl. Currently sh chokes on the # after -- as the executable.

[503] x.pl 
#: Can't open #

What should be happening is sh strips everything including and after
the #. With no args the file should be executed in the same sh. Then
the eval/exec will transfer responsibility to perl. This works on
DEC UNIX, linux, and several others.

>How-To-Repeat:
Run the following script:

#!/bin/sh -- # -*- perl -*-

eval "exec perl $0 -S ${1+'$@'}"
  if 0;

print "1+1=", (1+1), "\n";

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000127023759.19A7214E20>