Clunch protection

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Fri Oct 19 08:24:34 AEST 1984


> 1.  The "#!/bin/sh" line lacks a space or tab between the "#!" and the
>     "/bin/sh".
> 
> 2.  The "#!" construct is not recognized on all UNIX systems.
> 
> 3.  Even if the "#!/bin/sh" line is present at the start of a shell script,
>     "/bin/sh" will NOT be used to interpret the script if the script is
>     executed using the command
> 	csh script

1.  The documentation was wrong; white space was optional all along.
Later versions of the documentation have been corrected.  Only LOCUS
chose to force you to use white space, so far as I am aware.  By all
means stick in a space if it makes you happier.

2.  On most systems where the kernel does not understand the #! magic
number, the first line of the script will be taken as a comment and
the Bourne shell /bin/sh will be used to interpret the script anyway.
7th Edition UNIXes that never upgraded their shells may break.  Also,
systems where the Cshell was imported with insufficient care may let
the Cshell handle the script rather than either defaulting to the
native shell or examining the #! line to see what to use.

3.  Of course
	csh script
will use the wrong shell!  So will
	ed script
or many other similar commands.

4.  If one has to allow for || && vs && ||, lack of # comments, and
zillions of other variations, then immense pains are required to
produce anything close to a "portable" shell script that will either
run correctly or detect that it has been misinvoked.  The example that
started this discussion took great pains but still had loopholes; the
practicality of this approach is questionable.  It is perhaps easier
to give somebody a new shell than it is to accommodate WHATEVER he
might already have.



More information about the Comp.unix mailing list