Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site mtxinu.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!zehntel!dual!unisoft!mtxinu!ed From: ed@mtxinu.UUCP (Ed Gould) Newsgroups: net.unix Subject: Re: 2 shell questions before the new year Message-ID: <240@mtxinu.UUCP> Date: Sun, 6-Jan-85 23:26:09 EST Article-I.D.: mtxinu.240 Posted: Sun Jan 6 23:26:09 1985 Date-Received: Wed, 9-Jan-85 01:45:28 EST References: <6820@brl-tgr.ARPA> Organization: mt Xinu, Berkeley, CA Lines: 32 > > 2. Why begin a shell script with > > > > #!/bin/sh > > or > > #!/bin/csh > > This tells the C shell which shell is supposed to interpret the > shell script. It's necessary because the syntax of shell > commands is different in the two shells; I think /bin/sh is used > by default. However, if the script starts with a # and doesn't > have the ! construct, the C shell is used On recent 4bsd systems (certainly 4.2, I believe 4.1 and don't remember before) this construct also allows the file to be handled by the kernel's exec() routine. The documented syntax is #! pathname arg where the space after the ! (exactly one space character, or perhaps either one space or one tab) is required, and there may be no more than one argument. (In reality, the space has never to my knowledge been required.) The advantages of directly-execable scripts are two-fold. First, it allows *any* interpreter to be specified for the rest of the file, not just a shell. Second, the set-uid and set-gid bits are honored. Voila! Set-uid shell scripts! -- Ed Gould mt Xinu, 739 Allston Way, Berkeley, CA 94710 USA {ucbvax,decvax}!mtxinu!ed +1 415 644 0146 (I'd rather not be parochial.)