# not honored?

Jonathan I. Kamens jik at athena.mit.edu
Thu Mar 29 09:12:08 AEST 1990


In article <MCDANIEL.90Mar28143721 at rollmops.amara.uucp>, mcdaniel at amara.uucp
(Tim McDaniel) writes:
> But I had thought that "#" as the first byte of a file meant "this is
> a C shell script" (unless, of course, the first two bytes are "#!").
> It appears that the Bourne shell does not respect this rule.
> Should it?  (On systems where the C shell exists and uses this
> convention.)

  This is *almost* right.

  "#" as the first byte of a file means "this is a C shell script" *only
if the script is being executed by the C shell*.  While "#!" is a kernel
thing, the "#" by itself thing is figured out by the C shell, not by the
kernel.  From the man page csh(1):

     Since many systems use
     either the standard version 6 or version 7 shells whose
     shell scripts are not compatible with this shell, the shell
     will execute such a `standard' shell if the first character
     of a script is not a `#', i.e. if the script does not start
     with a comment.

Therefore, if your script has to always be executed by the C shell, even
when it is executed by someone using another shell, you *must* have the
"#!/bin/csh -f" at the top.

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list