Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!inuxc!iuvax!bsu-cs!zoo-hq!dhesi From: dhesi@zoo-hq.UUCP Newsgroups: comp.unix.questions Subject: Re: Why does this shell program run under csh???? Message-ID: <5@zoo-hq.UUCP> Date: Fri, 5-Jun-87 03:11:27 EDT Article-I.D.: zoo-hq.5 Posted: Fri Jun 5 03:11:27 1987 Date-Received: Sun, 7-Jun-87 01:49:10 EDT References: <243@kosman.UUCP> <1270@ssc-vax.UUCP> <5943@brl-smoke.ARPA> Reply-To: iuvax!bsu-cs!dhesi (Rahul Dhesi) Organization: Zoo Headquarters, Muncie, Indiana Lines: 29 In article <5943@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) (discussing how the exec() system call works on non- a.out executable files) writes: > ....Many implementations of csh stupidly then >peek at the first character of the script and if it's "#" >they assume it must be a csh script rather than an sh script. >(That's a BUG. All my sh scripts but one start with "#".) I don't know if it's csh that peeks at that #, or if it's the library routine that does it before deciding whether to call the kernel's exec() routine, or the kernel exec() routine itself, or all of them. In any case, it's a FEATURE and not a bug. It is a generalized feature that will allow multiple shells and their scripts to coexist. 4.3BSD works very nicely with however many shells you have -- just make sure each shell script begins with "#! /bin/sh" or "#! /bin/csh -f" etc. System V chokes when it sees a csh script, because there is no uniform mechanism to handle multiple shells (this based on what I see on my UNIX PC and my Microport SVR2 systems). (It's supposed to work if you put a ": use /bin/csh" line at the beginning of a script. It doesn't.) In defense of the default csh interpreter obtained when # is not followed by an exclamation mark: Wasn't there a time when the Bourne shell did NOT accept # as a comment character? If so, and if csh was the first shell to use # for comments, it makes perfect sense that # implies a csh script. -- Rahul Dhesi UUCP: {seismo,ihnp4}!{pur-ee,iuvax}!bsu-cs!dhesi