Clunch protection
Arthur David Olson
ado at elsie.UUCP
Wed Oct 17 00:40:51 AEST 1984
brl-tgr!gwyn:
> #!/bin/sh
> on line 1 will let the kernel exec the script using the correct shell
> no matter what shell the user is running at the time.
1. The "#!/bin/sh" line lacks a space or tab between the "#!" and the
"/bin/sh". Quoting the second page of the exec(2) page in the UNIX
Programmer's Manual for the Fourth Berkeley Software Distribution
(dated 4/1/81--April Fools' Day), "The space (or tab) following the '#!'
is mandatory." While some implementations may not require the space, it
behooves those of us interested in portability to use the documentation
when trying to create portable scripts, rather than finding out what we
can "get away with" on a particular system.
2. The "#!" construct is not recognized on all UNIX systems. Some may respond
that anyone who'd continue running a system that fails to recognize "#!"
"ougtht to" upgrade. Alas, in the real world, there are legitimate
economic, political, and legal reasons for staying with older versions of
UNIX; those using older versions are ill-served by folks who would lecture
them to upgrade rather than try to keep their needs in mind.
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
(This is, at any rate, true on 4.1bsd and 4.2bsd). "Clunch protection"
lines are designed to guard against this possibility. Some may respond
that anyone who'd use the above command is a clunch; a moment's
reflection. . .
--
UNIX is an AT&T Bell Laboratories trademark.
"sh" may be a American Librarians' Association trademark.
--
..decvax!seismo!elsie!ado (301) 496-5688
DEC, VAX and Elsie are Digital Equipment and Borden trademarks
More information about the Comp.unix
mailing list