Shell programming style -- a pl

donn at hp-dcd.UUCP donn at hp-dcd.UUCP
Sun Mar 11 04:32:00 AEST 1984


Careful with #!;  If you are running csh on a USG UN*X system
(System III or V), #! doesn't work.  The line #!/bin/sh will then
be seen by csh (after the exec fails), treated as a comment, and
cause csh to assume that it's a csh script (csh assumes that a file
beginning with # is a csh script).  System III and V, but
not V7, sh treat anything after a # as a comment.  The only safe 
form I know of across ALL systems is to write a script that begins
with a space:

 #  This is a /bin/sh script
echo hi there

If you have #!, then Doug's proposal will work.

This applies definitely to 4.1 csh, etc; I havn't tested it against
4.2, but I suspect it still applies.

Donn Terry
hplabs!hp-dcd!donn



More information about the Comp.unix mailing list