Discussion:
Posix is silent; Open Group is silent; feature is SVR4 & 4.3+BSD
Neil W. Van Dyke
2001-05-22 04:59:19 UTC
Permalink
I'm pretty sure I've seen '90s-era workstation Unixen that don't
tolerate a space between the "#!" cookie and the pathname to the
executable.

All other things being equal, I'd prefer SRFI not criminalize the act of
Scheme scripting on oddball Unixen. :)

Forbidding the space would be compatible with all Unixen, though not
with all current Scheme implementations.
--
Neil W. Van Dyke <nwv-***@public.gmane.org>
http://www.neilvandyke.org/
Bengt Kleberg
2001-05-22 08:13:57 UTC
Permalink
Post by Neil W. Van Dyke
I'm pretty sure I've seen '90s-era workstation Unixen that don't
tolerate a space between the "#!" cookie and the pathname to the
I have seen '80s-era mini-super computers that only worked _with_ a space.
They read the first 4 bytes of a file to decide what to do with it.
Marc Feeley
2001-05-22 12:10:11 UTC
Permalink
Post by Bengt Kleberg
Post by Neil W. Van Dyke
I'm pretty sure I've seen '90s-era workstation Unixen that don't
tolerate a space between the "#!" cookie and the pathname to the
I have seen '80s-era mini-super computers that only worked _with_ a space.
They read the first 4 bytes of a file to decide what to do with it.
Rather than speculate about all the possible differences (/usr/bin/env
vs. /bin/env, 32 character limit, space vs. no space), how about
trying it out on a bunch of Unix implementations and reporting the
results?

Even if a standard exists and is documented somewhere, such a survey
might point out that some implementations of Unix don't implement the
standard correctly, or that all the "mainstream" Unix implementations
support a particular style of script.

For this purpose I have written the script attached below. Just put
it in the file "testscript", type "source testscript" on the Unix
implementations you have access to, and report the output (all
temporary file are cleaned up). Here is the output for Linux (which
is basically the same for MacOS X, i.e. /bin/env does not exist)

% source testscript
testscript 1.0
Linux trex.IRO.UMontreal.CA 2.2.19pre10 #2 SMP Mon Feb 12 14:21:35 EST 2001 i686 unknown
Tue May 22 07:51:38 EDT 2001
-------------------- ./script1
#! /usr/bin/env cat
-------------------- ./script2
#!/usr/bin/env cat
-------------------- ./script3
#! /usr/bin/env cat
#! /usr/bin/env ./script3-helper-file890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script4
#!/usr/bin/env cat
#!/usr/bin/env ./script4-helper-file7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script5
sh: ./script5: No such file or directory
-------------------- ./script6
sh: ./script6: No such file or directory
-------------------- ./script7
sh: ./script7: No such file or directory
-------------------- ./script8
sh: ./script8: No such file or directory


Marc

--------------8<--------------8<--------------8<--------------8<--------------
sh <<EOF
echo "testscript 1.0"
uname -a
date
mkdir testscript-tmp
cd testscript-tmp
echo "#! /usr/bin/env cat" > script1
echo "#!/usr/bin/env cat" > script2
echo "#! /usr/bin/env ./script3-helper-file890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567" > script3
echo "#! /usr/bin/env cat" > script3-helper-file890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
echo "#!/usr/bin/env ./script4-helper-file7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567" > script4
echo "#!/usr/bin/env cat" > script4-helper-file7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
echo "#! /bin/env cat" > script5
echo "#!/bin/env cat" > script6
echo "#! /bin/env ./script7-helper-file4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567" > script7
echo "#! /bin/env cat" > script7-helper-file4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
echo "#!/bin/env ./script8-helper-file34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567" > script8
echo "#!/bin/env cat" > script8-helper-file34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
chmod 755 script1 script2 script3 script3-helper-file890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 script4 script4-helper-file7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 script5 script6 script7 script7-helper-file4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 script8 script8-helper-file34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
echo -------------------- ./script1
./script1
echo -------------------- ./script2
./script2
echo -------------------- ./script3
./script3
echo -------------------- ./script4
./script4
echo -------------------- ./script5
./script5
echo -------------------- ./script6
./script6
echo -------------------- ./script7
./script7
echo -------------------- ./script8
./script8
rm -f script1 script2 script3 script3-helper-file890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 script4 script4-helper-file7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 script5 script6 script7 script7-helper-file4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 script8 script8-helper-file34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
cd ..
rmdir testscript-tmp
EOF
--------------8<--------------8<--------------8<--------------8<--------------
Martin Gasbichler
2001-05-22 15:28:11 UTC
Permalink
Marc> For this purpose I have written the script attached below. Just put
Marc> it in the file "testscript", type "source testscript" on the Unix
Marc> implementations you have access to, and report the output (all
Marc> temporary file are cleaned up). Here is the output for Linux (which
Marc> is basically the same for MacOS X, i.e. /bin/env does not exist)

testscript 1.0
IRIX64 test1 6.5
Tue May 22 17:14:43 MDT 2001
-------------------- ./script1
#! /usr/bin/env cat
-------------------- ./script2
#!/usr/bin/env cat
-------------------- ./script3
#! /usr/bin/env cat
#! /usr/bin/env ./script3-helper-file890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script4
#!/usr/bin/env cat
#!/usr/bin/env ./script4-helper-file7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script5
#! /bin/env cat
-------------------- ./script6
#!/bin/env cat
-------------------- ./script7
#! /bin/env cat
#! /bin/env ./script7-helper-file4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script8
#!/bin/env cat
#!/bin/env
./script8-helper-file34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567

testscript 1.0
HP-UX test2 B.10.20 A 9000/785
Tue May 22 17:14:49 METDST 2001
-------------------- ./script1
#! /usr/bin/env cat
-------------------- ./script2
#!/usr/bin/env cat
-------------------- ./script3
#! /usr/bin/env cat
#! /usr/bin/env ./script3-helper-file890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script4
#!/usr/bin/env cat
#!/usr/bin/env ./script4-helper-file7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script5
#! /bin/env cat
-------------------- ./script6
#!/bin/env cat
-------------------- ./script7
#! /bin/env cat
#! /bin/env ./script7-helper-file4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script8
#!/bin/env cat
#!/bin/env ./script8-helper-file34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567

(Thanks to Richard Günther)
--
Martin
Bengt Kleberg
2001-05-22 12:34:27 UTC
Permalink
...deleted
Post by Marc Feeley
Rather than speculate about all the possible differences (/usr/bin/env
vs. /bin/env, 32 character limit, space vs. no space), how about
trying it out on a bunch of Unix implementations and reporting the
results?
...deleted

Results included below.
Post by Marc Feeley
For this purpose I have written the script attached below. Just put
it in the file "testscript", type "source testscript" on the Unix
...deleted

Just a minor detail, but 'source' only works in csh (and derivates,
presumably including bash). 'Normal' shells (sh, ksh and rc :-), use
'.' instead. As in '. testscript'.

The results:

testscript 1.0
SunOS avc280 5.7 Generic_106541-15 sun4u sparc SUNW,Ultra-5_10
Tue May 22 14:24:06 MET DST 2001
-------------------- ./script1
#! /usr/bin/env cat
-------------------- ./script2
#!/usr/bin/env cat
-------------------- ./script3
#! /usr/bin/env cat
#! /usr/bin/env ./script3-helper-file890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script4
#!/usr/bin/env cat
#!/usr/bin/env ./script4-helper-file7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script5
#! /bin/env cat
-------------------- ./script6
#!/bin/env cat
-------------------- ./script7
#! /bin/env cat
#! /bin/env ./script7-helper-file4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
-------------------- ./script8
#!/bin/env cat
#!/bin/env ./script8-helper-file34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
Loading...