Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site unisoft.UUCP Path: utzoo!watmath!clyde!akgua!mcnc!decvax!ucbvax!ucbtopaz!unisoft!ed From: ed@unisoft.UUCP Newsgroups: net.unix Subject: Re: #! in shell scripts Message-ID: <235@unisoft.UUCP> Date: Sat, 17-Mar-84 21:01:10 EST Article-I.D.: unisoft.235 Posted: Sat Mar 17 21:01:10 1984 Date-Received: Sun, 18-Mar-84 08:34:06 EST References: <1773@rlgvax.UUCP> Organization: UniSoft Corp., Berkeley Lines: 24 It is my understanding that the #! magic number was suggested by Dennis Ritchie and implemented by Dennis and/or Bill Joy. In any case, the idea seems to have come from Bell. Its original motivation was not particularly for shell scripts, however, but to deal with the output of "pi", which is a translator from Pascal to an interpreted intermediate code. To execute the intermediate, "px" is used. It seemed nice to be able to utter just the name of the pi output file to get it executed, rather than "px filename". (There was actually a kludge put in to the pi output files to make them executable, but it was pretty expensive to start up as it involved an extra fork, exec, and pipe.) Thus was born the "specified interpreter" magic number #!. These characters were chosen for compatibility with existing shell scripts. Having the kernel recognize this extra magic number, as has been pointed out by several others, is not particularly expensive, since the kernel already reads the exec header from the file to determine if it's executable at all. -- Ed Gould ucbvax!mtxinu!ed