Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site hropus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!houxm!hropus!ka From: ka@hropus.UUCP (Kenneth Almquist) Newsgroups: net.unix-wizards Subject: Re: Shell history Message-ID: <358@hropus.UUCP> Date: Mon, 17-Mar-86 10:52:54 EST Article-I.D.: hropus.358 Posted: Mon Mar 17 10:52:54 1986 Date-Received: Wed, 19-Mar-86 00:41:45 EST References: <1512@brl-smoke.ARPA> <140@umcp-cs.UUCP> <542@mtxinu.UUCP> <71@cascade.ARPA> <214@isieng.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 46 > Old shell scripts ran successfully with the Bourne shell, which is why > he could get away with replacing the old shell completely. Actually, they generally didn't. I'll give an example of a pre-Bourne shell script for those of you who are curious: /bin/if $1x = x /bin/goto usage [commands to do actual work go here] /bin/exit : usage /bin/echo "Usage: command filename" /bin/exit 1 Several commands here no longer exist. The program /bin/if evaluated conditional expressions. The expression "$1x = x" tests whether $1 is the null string. (This looks like a silly way to do this, I know. I think that the reason it was done this way is that $1 would not be expanded if it was enclosed in quotes.) If the expression evaluated to true, /bin/if would execute the specified program: /bin/goto in this case. /bin/goto performs a goto, just like its name implies. The implemen- tation of /bin/goto depended upon the fact that the shell read shell scripts on file descriptor 0 using unbuffered reads. The /bin/goto program would seek to the beginning of the script and read forward until it came to the specified label, which appeared on a line begin- ning with a ":". The ":" command does nothing; it was actually a shell builtin even at this early date. /bin/exit was a very simple program. It just seeked to the end of file on its standard input. The second example worked because sh would use (and still uses) the exit status of the last command invoked as its exit status, so "/bin/exit 1" would seek to the end of file and then exit with status of 1, which would cause the shell to terminate with the same status. Needless to say, all this broke with the Borne shell, which didn't read shell scripts on the standard input. One reason that the Borne shell was accepted as a replacement for the old shell is that in a shell script of any size the gotos became unreadable. The big change in converting to the Borne shell consisted of replacing all the gotos with structured flow of control statements, which was obviously a worthwhile enterprise even if the Borne shell had not required it. Kenneth Almquist ihnp4!houxm!hropus!ka (official name) ihnp4!opus!ka (shorter path)