Re: Posix is silent; Open Group is silent; feature is SVR4 & 4.3+BSD Marc Feeley (22 May 2001 12:10 UTC)

Re: Posix is silent; Open Group is silent; feature is SVR4 & 4.3+BSD Marc Feeley 22 May 2001 12:10 UTC

> > From: "Neil W. Van Dyke" <xxxxxx@acm.org>
> > To: srfi-22@srfi.schemers.org
>
> > 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<--------------