| Bourne shell | |
|---|---|
Bourne shell interaction onVersion 7 Unix | |
| Original author | Stephen Bourne |
| Developer | Bell Telephone Laboratories |
| Initial release | 1979; 47 years ago (1979) |
| Operating system | Unix |
| Type | Unix shell |
| License | [under discussion] |
TheBourne shell (sh) is ashellcommand-line interpreter for computeroperating systems. It first appeared onVersion 7 Unix, as its defaultshell.Unix-like systems continue to have/bin/sh—which will be the Bourne shell, or asymbolic link orhard link to a compatible shell—even when other shells are used by most users.
The Bourne shell was once standard on all brandedUnix systems, although historicallyBSD-based systems had many scripts written incsh. As the basis ofPOSIXsh syntax, Bourne shell scripts can typically be run withBash ordash onLinux or other Unix-like systems; Bash itself is afree clone of Bourne.

Work on the Bourne shell initially started in 1976.[1] Developed byStephen Bourne atBell Labs, it was a replacement for theThompson shell, whose executable file had the same name—sh. The Bourne shell was also preceded by theMashey shell. Bourne was released in 1979 in theVersion 7 Unix release distributed to colleges and universities. Although it is used as an interactive command interpreter, it was also intended as ascripting language and contains most of the features that are commonly considered to produce structured programs.
It gained popularity with the publication ofThe Unix Programming Environment byBrian Kernighan andRob Pike—the first commercially published book that presented the shell as a programming language in a tutorial form.[citation needed]
Some of the primary goals of the shell were:[2]
Features of the Version 7 UNIX Bourne shell include:
`command`.<< to embed a block of input text within a script.for ~ do ~ done loops, in particular the use of$* to loop over arguments, as well asfor ~ in ~ do ~ done loops for iterating over lists.case ~ in ~ esac selection mechanism, primarily intended to assistargument parsing.sh provided support for environment variables using keyword parameters and exportable variables.The Bourne shell also was the first to feature the convention of usingfile descriptor2> forerror messages, allowing much greater programmatic control during scripting by keeping error messages separate from data.
Stephen Bourne's coding style was influenced by his experience with theALGOL 68C compiler[3] that he had been working on atCambridge University. In addition to the style in which the program was written, Bourne reused portions ofALGOL 68'sif ~then ~elif ~then ~else ~fi,case ~in ~esac andfor/while ~do ~od" (usingdone instead ofod) clauses in the commonUnix Bourne shell syntax. Moreover, – although the v7 shell is written inC – Bourne took advantage of somemacros[4] to give the Csource code an ALGOL 68 flavor. These macros (along with thefinger command distributed in Unix version4.2BSD) inspired theInternational Obfuscated C Code Contest (IOCCC).[5]
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, System III, SVR2, SVR3, SVR4). As the shell was never versioned, the only way to identify it was testing its features.[6]
Features of the Bourne shell versions since 1979 include:[7]
test command – System III shell (1981)continue with argument – System III shell (1981)cat <<-EOF for indented here documents – System III shell (1981)return builtin – SVR2 shell (1984)unset,echo,type – SVR2 shell (1984)$@" – SVR3 shell (1986)getopts – SVR3 shell (1986)Duplex Multi-Environment Real-Time (DMERT) is a hybrid time-sharing/real-time operating system developed in the 1970s at Bell Labs Indian Hill location inNaperville, Illinois uses a 1978 snapshot of Bourne Shell "VERSION sys137 DATE 1978 Oct 12 22:39:57".[citation needed] The DMERT shell runs on3B21D computers still in use in the telecommunications industry.[citation needed]

The Korn shell (ksh) written byDavid Korn based on the original Bourne Shell source code,[8] was a middle road between the Bourne shell and theC shell. Its syntax was chiefly drawn from the Bourne shell, while itsjob control features resembled those of the C shell. The functionality of the original Korn Shell (known as ksh88 from the year of its introduction) was used as a basis for thePOSIX shell standard. A newer version, ksh93, has been open source since 2000 and is used on someLinux distributions. A clone of ksh88 known aspdksh is the default shell in OpenBSD.
Jörg Schilling's Schily-Tools includes three Bourne Shell derivatives.[9]
Bill Joy, the author of the C shell, criticized the Bourne shell as being unfriendly for interactive use,[10] a task for which Stephen Bourne himself acknowledged C shell's superiority. Bourne stated, however, that his shell was superior for scripting and was available on any Unix system,[11] andTom Christiansen also criticized C shell as being unsuitable for scripting and programming.[12]
Due to copyright issues surrounding the Bourne Shell as it was used in historicCSRG BSD releases, Kenneth Almquist developed a clone of the Bourne Shell, known by some as the Almquist shell and available under theBSD 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 theDebian Almquist shell, or dash. This shell provides faster execution of standardsh (and POSIX-standardsh, in modern descendants) scripts with a smallermemory footprint than its counterpart, Bash. Its use tends to exposebashisms – bash-centric assumptions made in scripts meant to run on sh.
Instead of inventing a new script language, we built a form entry system by modifying the Bourne shell, adding built-in commands as necessary.