Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!uflorida!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: Bourne Shell Comments Problem Keywords: Bourne Shell UNIX Problem Message-ID: <13710@mimsy.UUCP> Date: 23 Sep 88 15:33:32 GMT References: <292@dsacng1.UUCP> <1133@usfvax2.EDU> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 86 In article <1133@usfvax2.EDU> ssi@usfvax2.EDU (Ssi) writes: >The problem is just that. Placing a '#' there means you want to >run the script in the csh shell. Indeed. As you mortals say :-), what goes around, comes around. (Message save:98) Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site maryland.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site umcp-cs.UUCP Path: maryland!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: # sign in shell/cshell scripts... Message-ID: <995@umcp-cs.UUCP> Date: 17 Apr 86 20:30:30 GMT Date-Received: 17 Apr 86 20:30:30 GMT References: <237@Shasta.ARPA> Reply-To: chris@maryland.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 57 In article <237@Shasta.ARPA> ALEX@SU-SIERRA.ARPA writes: > 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: ># This script does this (but not that) Once upon a time, there was the shell. Since there was only `the' shell, there was no trouble deciding how to run a script: run it with *the* shell. It worked, and everyone was happy. Along came progress, and wrote another shell. The people thought this was good, for now they could choose their own shells. So some chose the one, and some the other, and they wrote shell scripts and were happy. But one day someone who used the `other' shell ran a script by someone who use the `other other' shell, and alas! it bombed spectacularly. The people wailed and called upon their Guru for help. `Well,' said the Guru, `I see the problem. The one shell and the other are not compatible. We must ensure that the shells know which other shell to use to run each script. And lo! the one shell has a ``comment'' called ``:'', and the other a true comment called ``#''. I hereby decree that henceforth, the one shell will run scripts that start with ``:'', and the other those that start with ``#''.' And it was so, and the people were happy. But progress was not finished. This time he noticed that only shells ran scripts, and thought that if the kernel too could run scripts, that this would be good, and the people would be happy. So he wrote more code, and now the kernel could run scripts, but only if they began with the magic incantation: `#!', and told the kernel which shell ran the script. And it was so, and the people were confused. For the `#!' looked like a `comment'. Though the kernel could see the `#!' and run a shell, it would not do so unless certain magic bits were set. And if the incantation were mispronounced, that too could stop the kernel, which after all was not omniscient. And so the people wailed, but alas!, the Guru did not respond. And so it was, and still it is today. * * * * * Anyway, you will get best results from a 4BSD machine by using #! /bin/sh or #! /bin/csh as the first line of your script. `#! /bin/csh -f' is also helpful on occasion. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu And a recent addendum: System III and System V, and systems derived from them, usually do *not* support `#!'. Alas, if you use it, you may get the wrong shell. Of course, System III and System V do not come with the C shell either. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris