Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site onfcanim.UUCP Path: utzoo!watmath!watnot!watcgl!onfcanim!dave From: dave@onfcanim.UUCP (Dave Martindale) Newsgroups: net.unix-wizards Subject: Re: # sign in shell/cshell scripts... Message-ID: <14810@onfcanim.UUCP> Date: Thu, 17-Apr-86 12:40:51 EST Article-I.D.: onfcanim.14810 Posted: Thu Apr 17 12:40:51 1986 Date-Received: Fri, 18-Apr-86 04:46:07 EST References: <237@Shasta.ARPA> Reply-To: dave@onfcanim.UUCP (Dave Martindale) Organization: ONF, Montreal Lines: 33 In article <237@Shasta.ARPA> ALEX@SU-SIERRA.ARPA writes: >Hi, > I'm encountering weird problems with sh (and sometimes csh) >dying on some shell scripts depending on whether or not my first line in >the script is a comment like: > > I am looking for ANY hint/story/random knowledge concerning ># in shell scripts. In the beginning, there was only the one true shell, and it knew that shell scripts were to be run by itself. In recent times, many versions of UNIX support the convention that a script beginning with #! signals that a particular (arbitrary) program is to be used to execute the script, and invoking the correct interpreter is handled by the kernel. Sometime in between those two times, there existed UNIX systems that had both a "sh" shell and a "csh" shell but no "#!" mechanism, and the shells (or at least the csh) established a convention that a shell script the began with a comment ('#') was a csh script, otherwise it was a sh script. So, your shell is probably one of these shells, and is deciding to run either sh or csh depending on where you put your first comment. Since the control structures for sh and csh are so different, no wonder the chosen shell gets indigestion if fed a script written for the other shell. Note that even if your kernel does support #!, the old code in the sh/csh may not have been disabled. But it doesn't matter - if you do have #!, just begin your scripts with "#! /bin/sh" or "#! /bin/csh -f" as appropriate.