The Bourne shell, or sh, was the default Unix shell of Unix Version 7, and replaced the Thompson shell, whose executable file had the same name, sh. It was developed by Stephen Bourne, of AT&T Bell Laboratories, and was released in 1977 in the Version 7 Unix release distributed to colleges and universities. It remains a popular default shell for Unix accounts. The binary program of the Bourne shell or a compatible program is located at
/bin/sh on most Unix systems, and is still the default shell for the root superuser on many current Unix implementations.
Among the primary goals were:
The Bourne shell also was the first to feature the convention of using file descriptor
2> for error messages, allowing much greater programmatic control during scripting by keeping error messages separate from data.
Other innovations in this shell included:
to embed a block of input text within a script.
for ~ do ~ done" loops, in particular the use of
to loop over arguments.
case ~ in ~ esac" selection mechanism, primarily intended to assist argument parsing.
shprovided support for environment variables using keyword parameters and exportable variables.
Over the years, the Bourne shell was enhanced at AT&T. The various variants are thus called like the respective AT&T Unix version it was released with (some important variants being Version7, SystemIII, SVR2, SVR3, SVR4). As the shell was never versioned, the only way to identify it was testing its features.
Stephen Bourne carried into this shell some aspects of the ALGOL 68C compiler that he had been working on at Cambridge University. Notably he reused portions of ALGOL 68's "
if ~ then ~ elif ~ else ~ fi", "
case ~ in ~ out ~ esac" and "
for ~ while ~ do ~ od" clauses in the common Unix Bourne shell syntax. Moreover - although the v7 shell is written in C - Bourne took advantage of some macros to give the C source code an ALGOL 68 flavor. These macros co-inspired the IOCCC - International Obfuscated C Code Contest (Co-inspired with the finger command as distributed in Unix version 4.2BSD).
Due to copyright issues surrounding the Bourne Shell as it was used in historic CSRG BSD releases, Kenneth Almquist developed a clone of the Bourne Shell, known by some as the Almquist Shell and available under the BSD license, which is in use today on some BSD descendants and in low-memory situations. The Almquist Shell was ported to Linux, and the port renamed the Debian Almquist shell, or dash. This shell provides much faster execution of standard sh scripts with a smaller memory footprint than its more common counterpart, bash. Its use tends to expose bashisms - bash-centric assumptions made in scripts meant to run on sh.