The Traditional Bourne Shell Family

Development and History

13-11-2003


This page is about all the variants of the original Bourne shell, it does't deal with bourne compatible shells (korn, almquist, bourne again, etc.)

Originally, this started with a rough english translation of <3B9529F8.2RV1IN16U@bigfoot.de> from de.comp.os.unix.shell. Credits for that posting and for countless further comments to Gunnar Ritter. Without The Unix Heritage Society (TUHS) the first half of this page wouldn't have been possible. Many thanks also to Dennis Ritchie for documentation about the Version 8 shell and to Warren Toomey (TUHS) for documentation about the SVR1 shell.

I inspected the Bourne shell on these unix systems. If you have access to a different one, i really would like to hear from you.

Keep in mind that the Bourne shell is not necessarily /bin/sh [1].

Find more information about the origins of the Bourne shell at the bottom of this page.

Todo: Bourne shell before Version 7 (unreleased), a better look at the various SVR4.x

An often undocumented but characteristic feature common to all traditional Bourne shells (except for "Version 8") which is not existent in other shells: You can use the circumflex '^' (caret) as replacement for the pipe symbol '|'. See more common characteristics of the traditional Bourne shells distinguishing them from their successors.


Recent changes to this page.

The item "Version 7 " only lists some main differences to current shells. See also the linked manual page for more information.
All subsequent items list the differences (new features as well as bugfixes) to predecessors; i.e., go backwards to nail down the V7 shell.








Footnotes for the list above:

[1] Naturally, virtually all commercial systems provide a traditional Bourne shell. Meanwhile, you'll find it at a path different from /bin/sh on several systems (e.g., HP-UX 10 ff.) or under the different name bsh (e.g., on AIX 4 ff. and IRIX 6.4 ff.). See also various system shells.
No rule without exception: On HP-UX 11i Version 1.5 and ff. the Bourne shell is not shipped anymore.

[2] A Bourne shell not being 8-bit clean shows subtle bugs, e.g., when using ${b="$a"} with $a containing spaces: The internal quoting mechanism sets the 8th bit for all characters due to the doublequotes, and thus $b won't contain real spaces aymore. This can be demonstrated with "for i in $b; do echo $i; done" (but not with "echo $b" because then the 8th bit certainly gets unset again).

[3] In the traditional BSD line, the Bourne shell was shipped until 4.3BSD-Reno (but not anymore with Net/2 and the following 4.4BSDs). For license reasons it was then substituted with the bourne-compatible, svr4-like ash by Kenneth Almquist.

[4] SINIX 5.20 offers three socalled universes: "ucb", "sie"(mens) and "xopen" (aka "att"). These provide shells from 4.2BSD, SystemIII and SVR3, respectively. See some notes about the sinix universes if you are curious.

[5] Most modifications for the Version 8 shell were driven by the motivation for a clean design. Interestingly, the fact that function calls overwrite the positional parameters was not changed.

[6] The Migration Guide " System V Environment for Digital UNIX Version 4.0." (560 kB PDF) claims, that /bin/sh on OSF1/V4 and /V5 is a SVR3.2 shell. However, it's missing a few characteristic properties of this shell (modern "$@", "getopts" and the PATH fix). After all, it seems more likely, that it is a heavily extended SVR2 shell.

[7] To try the unicode support on HP-UX, you need an according font and the ability to insert multi-byte characters. I prefer Thomas Dickey's XFree86 Xterm with Markus Kuhn's fonts. Set LC_COLLATE and LC_CTYPE after looking at "locale -a" and also set "stty -istrip cs8".

[8] On SunOS 4, the "ulimit" built-in is not implemented at all. getrlimit(2) lists this under BUGS (but in fact this origins from 4.2BSD). File size limits are catched with quotas instead, and apparently Sun didnt't want to add support by getrlimit(2) otherwise.

[9] If you run an older shell without job control: Don't forget about nohup(1). However, note that background jobs are not in a new process group, which has again a strong influence on signal handling.

[10] The version on IRIX 5.x ff.
  • apparently originates somewhere from between SVR4 and SVR4.2:
    • it knows "echo -n" (not very significant)
    • "type" reports "priv" and "mldmode" as built-ins.
      But in fact they are disabled: you get "Unknown builtin" when calling them.
    • the SVID strings "UX:sh", "ERROR:", "WARNING", etc are contained in the binary, but not activated (contrary to the jsh(1) notes).
  • provides ${parameter##pattern} expansion, for the pattern "*/" only. The reason is: /sbin/builtin_exec reads '${0##*/} "$@"' and there are softlinks pointing to this file with the name of the POSIX.2 built-ins.

[11] sh on DG/UX 4.20 knows about the "UX:sh:" message and seems to originate from between SVR4.0 and SVR4.2. As specific extensions it provides command line editing and a "readt" built-in (timing out).


Origins of the Bourne shell

See an article from John Mashey in net.unix-wizards ('86). By the way, the Mashey shell from the Programmer's Workbench, about "PWB 1.0", is also archived by TUHS.

See also an article by David Korn ('94) with an interesting second chapter concerning the Bourne shell history.

(The Bourne shell would probably be in much wider interactive use today, if it provided line editing (and a history mechanism). Having the above article in mind, this was (like with ksh originally) probably not done in the hope that these features would move into the terminal driver?)

See manual pages of two main predecessors of the Bourne shell, the "Thompson" and the "Mashey" shell:

as well as the


I collected some enlightening notes about the memory management, i.e., using sbrk(2) and trapping SIGSEGV.


Meanwhile the early Unix variants have become available in source under a BSD-like license from SCO, have look at TUHS. Usually you will not be able to easily compile earlier Bourne shells on a modern unix variant, as it is really oldfashioned C code with wild pointer management, as the internal memory management crashes the malloc used in libc nowadays and as it's using an older UNIX API (especially for directory access). The source is also odd to read without preprocessing (e.g., it is made "algol-like" with preprocessor macros). Apart from just running V7 and its shell in an emulator like simh:

Geoff Collyer provides a source package of the V7 shell which should compile on most POSIX systems. He has updated the memory management and directory-access code with parts from his V9 shell. However he has added a few minor modifications, so it's not an original reimplementation.

He has also written "a partial tour through the unix shell", quite important if you want to get busy with the source. It's emphasizing the memory management but also contains general hints.


<http://www.in-ulm.de/~mascheck/bourne/>

Sven Mascheck <mascheck at in-ulm.de>

../