Bourne Shell Comments Problem

Doug Gwyn gwyn at smoke.ARPA
Mon Oct 3 16:48:21 AEST 1988


In article <1628 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
>In article <8567 at smoke.ARPA>, gwyn at smoke.ARPA (Doug Gwyn ) writes:
>> Nearly all Bourne shell scripts I have encountered in the past
>> several years start with #.
>You must not have used systems with the csh available then, since csh (not
>sh) uses the first character to determine whether to pass the script off onto
>the bourne shell.

Csh on old BSD systems did this, since # was not a general comment
character in the really old version of the Bourne shell that they used.
Later a hack was added to permit a limited form of # comments in Bourne
shell scripts on BSD systems.  UNIX System V has always had general #
comments in Bourne shell scripts, and most scripts start with comments
describing what the script is for, etc.

However, a port of csh to UNIX System V should NOT "exec" scripts using
csh, and a Bourne shell even on BSD should never do this.  On BSD systems,
the #! kludge can be used to force the right interpreter; on UNIX System V
this is not usually supported, and since csh is not standard on UNIX
System V in that environment shell scripts should always be executed by a
Bourne shell (except for explicit "csh <foo" or "csh foo", of course).

I notice that few porters of csh to a UNIX System V environment seem to
be familiar enough with the UNIX System V environment to fix such
incompatibilities when they do the port.



More information about the Comp.unix.questions mailing list