Let's begin with 2 important bits of information before we get on with the story... =^)

  • Sixth Edition UNIX == Version 6 (V6) UNIX - It was released in May 1975 ;
  • Seventh Edition UNIX == Version 7 (V7) UNIX - It was released in 1979 ;

V7 UNIX & the shells

The Thompson shell, by Ken Thompson of Bell Labs, was distributed as the standard command interpreter, /bin/sh, through Version 6 (V6) UNIX. Then, in Version 7 (V7) UNIX, it was replaced by the Bourne shell. However, the Thompson shell was still distributed with the system as osh (see osh.c) because of known portability problems with the Bourne shell's memory management [1] in V7.

An updated version of the V6 Thompson shell was included, but its installation was incomplete. Specifically, there was no glob, if, or goto installed in V7 for the installed osh to use. That said, the included Thompson shell itself would have been enough to help fix things up on a bad Bourne shell day. Still, a shell I like (Thompson) was being replaced by one I don't (Bourne), and that's no fun for me. To be diplomatic though, I really can and do understand why.

In any case, I encourage you to read the memory management [1] page (linked to above) if you never have and/or to reread it if you already have. It's that important, and Dennis (dmr) sums up the Bourne shell's memory management / portability problems very nicely as well, shedding light so that we might better understand the story.

V6 UNIX & Ken's shell

Since it is not possible to appreciate the true nature of Ken Thompson's shell without having access to the original source code and documentation, this material is provided here under the following Caldera license (pdf) (local copy (pdf)) as a historical reference for the development of etsh. The following Version 6 (V6) UNIX source code and documentation was obtained from The UNIX Heritage Society (TUHS, see Dennis_v6). According to the details, these files were provided to TUHS by Dennis Ritchie [2].

The UNIX Time-Sharing System article gives the theory of operation of both the System and the Shell.

The shell made use of the following external utilities.

  • The exit(I) command, exit.c (installed as /bin/exit), was used to terminate command files.
  • The goto(I) command, goto.c (installed as /bin/goto), was used to transfer the shell's control from one point to another within a command file.
  • The if(I) command, if.c (installed as /bin/if), was used to evaluate conditional expressions. This is the predecessor of test(1), which was first released in Seventh Edition UNIX.
  • The glob(VIII) command, glob.c (installed as /etc/glob), was used to expand `*', `?', and `[...]' in command arguments.

Original V6 Manuals & Source Code

I have also made these available here, in their original extracted form (w/ license & license files added), via original_v6_manuals and original_v6_source_code. The reason I've done done so is simple for the manuals. You see, the manuals to which I've linked above have been modified so that they use the man(7) language. The originals, on the other hand, use roff as best I can remember, which doesn't work with any man program to which I have access. The source code is identical except that I didn't add the `NOTE:' comment about line counts/numbers and so forth. We might call it a needless redundancy for the moment.

See also

  1. Sven Mascheck, who maintains a website about the traditional Bourne shell family (including information about its origins), collected the referenced memory-management notes.
  2. Before his untimely passing, Dennis M. Ritchie maintained a great deal of important historical information about the early versions of the UNIX operating system on his Dennis Ritchie Home Page. It also includes some information about the shell.
  3. The Creation of the UNIX Operating System provides a very informative, and pleasant to read, account of the beginnings of the UNIX operating system.