Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!harpo!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.unix Subject: Re: Re: Shell programming style -- a pl Message-ID: <1803@rlgvax.UUCP> Date: Sun, 11-Mar-84 01:24:41 EST Article-I.D.: rlgvax.1803 Posted: Sun Mar 11 01:24:41 1984 Date-Received: Sun, 11-Mar-84 07:08:08 EST References: <16945@sri-arpa.UUCP> <34500004@hp-dcd.UUCP>, <1772@rlgvax.UUCP> <2189@brl-vgr.ARPA> <343@dual.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 29 When Doug said that "#!/bin/sh" at the beginning of a shell file would force the shell file to be executed on 4.2BSD, S3, and S5, I think he meant "S3 and S5 which haven't hacked the Bourne shell Berkeley-style to run scripts which begin with "#" with the C shell". That hack (having the Bourne shell run scripts that begin with "#" with the C shell, and having the C shell run scripts that begin with ":" with the Bourne shell) was done *before* "#" was allowed as a comment character in Bourne shell scripts. Now that it *is* allowed, that hack is based on an invalid assumption and should not be implemented. As such, any *sane* S3/S5 implementation of the Bourne shell won't feed scripts to the C shell if the script begins with "#". If you want to have a way to have scripts "select" the shell that they're to be executed by, the best solution is to bite the bullet and implement "#!". It's only 236 bytes of code on the VAX (I've pulled the code out and compiled it!), permits you to implement set-UID shell scripts, and has been blessed - hell, it was *invented* - by Dennis Ritchie himself. I know at least one commercial V7 micro-based system with the C shell implemented the heuristic based on the rule "Bourne shell scripts do not begin with '#', and C shell scripts do not begin with ':'", which was true in V7. It's *not* true in S3 or S5, so if anybody puts the C shell into their USG system they will *break things* if they put that rule into the Bourne shell. There are Bourne shell scripts *distributed with S3 and S5* which begin with "#", so don't even *think* about putting that heuristic in! If you need to put in some way to identify scripts as Bourne or C shell scripts, *please* send your $600 or whatever it is to the University of California, get a 4.xBSD tape, and implement "#!". Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy