Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site elsie.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!umcp-cs!cvl!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: net.unix Subject: Re: Clunch protection Message-ID: <4027@elsie.UUCP> Date: Tue, 16-Oct-84 10:40:51 EDT Article-I.D.: elsie.4027 Posted: Tue Oct 16 10:40:51 1984 Date-Received: Thu, 18-Oct-84 00:44:35 EDT References: <205@itm.UUCP> <5312@brl-tgr.ARPA> Organization: NIH-LEC, Bethesda, MD Lines: 36 brl-tgr!gwyn: > #!/bin/sh > on line 1 will let the kernel exec the script using the correct shell > no matter what shell the user is running at the time. 1. The "#!/bin/sh" line lacks a space or tab between the "#!" and the "/bin/sh". Quoting the second page of the exec(2) page in the UNIX Programmer's Manual for the Fourth Berkeley Software Distribution (dated 4/1/81--April Fools' Day), "The space (or tab) following the '#!' is mandatory." While some implementations may not require the space, it behooves those of us interested in portability to use the documentation when trying to create portable scripts, rather than finding out what we can "get away with" on a particular system. 2. The "#!" construct is not recognized on all UNIX systems. Some may respond that anyone who'd continue running a system that fails to recognize "#!" "ougtht to" upgrade. Alas, in the real world, there are legitimate economic, political, and legal reasons for staying with older versions of UNIX; those using older versions are ill-served by folks who would lecture them to upgrade rather than try to keep their needs in mind. 3. Even if the "#!/bin/sh" line is present at the start of a shell script, "/bin/sh" will NOT be used to interpret the script if the script is executed using the command csh script (This is, at any rate, true on 4.1bsd and 4.2bsd). "Clunch protection" lines are designed to guard against this possibility. Some may respond that anyone who'd use the above command is a clunch; a moment's reflection. . . -- UNIX is an AT&T Bell Laboratories trademark. "sh" may be a American Librarians' Association trademark. -- ..decvax!seismo!elsie!ado (301) 496-5688 DEC, VAX and Elsie are Digital Equipment and Borden trademarks