Original author(s) | Stephen Bourne |
---|---|
Developer(s) | Bell Telephone Laboratories |
Initial release | 1979 |
Operating system | Unix |
Type | Unix shell |
License | [ under discussion ] |
The Bourne shell (sh
) is a shell command-line interpreter for computer operating systems.
The Bourne shell was the default shell for Version 7 Unix. Unix-like systems continue to have /bin/sh
—which will be the Bourne shell, or a symbolic link or hard link to a compatible shell—even when other shells are used by most users.
Developed by Stephen Bourne at Bell Labs, it was a replacement for the Thompson shell, whose executable file had the same name—sh
. It was released in 1979 in the Version 7 Unix release distributed to colleges and universities. Although it is used as an interactive command interpreter, it was also intended as a scripting language and contains most of the features that are commonly considered to produce structured programs.
It gained popularity with the publication of The Unix Programming Environment by Brian Kernighan and Rob Pike—the first commercially published book that presented the shell as a programming language in a tutorial form.
Work on the Bourne shell initially started in 1976. [1] First appearing in Version 7 Unix, [2] the Bourne shell was preceded by the Mashey shell.
Some of the primary goals of the shell were: [3]
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 as for ~ in ~ do ~ done
loops for iterating over lists.case ~ in ~ esac
selection mechanism, primarily intended to assist argument 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 using file descriptor 2>
for error 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 the ALGOL 68C compiler [2] that he had been working on at Cambridge University. In addition to the style in which the program was written, Bourne reused portions of ALGOL 68's if ~ then ~ elif ~ then ~ else ~ fi
, case ~ in ~ esac
and for/while ~ do ~ od
" (using done
instead of od
) clauses in the common Unix Bourne shell syntax. Moreover, – although the v7 shell is written in C – Bourne took advantage of some macros [4] to give the C source code an ALGOL 68 flavor. These macros (along with the finger command distributed in Unix version 4.2BSD) inspired the International 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 in Naperville, Illinois uses a 1978 snapshot of Bourne Shell "VERSION sys137 DATE 1978 Oct 12 22:39:57".[ citation needed ] The DMERT shell runs on 3B21D computers still in use in the telecommunications industry.[ citation needed ]
The Korn shell (ksh) written by David Korn based on the original Bourne Shell source code, [8] was a middle road between the Bourne shell and the C shell. Its syntax was chiefly drawn from the Bourne shell, while its job 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 the POSIX shell standard. A newer version, ksh93, has been open source since 2000 and is used on some Linux distributions. A clone of ksh88 known as pdksh 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] and Tom 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 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 faster execution of standard sh
(and POSIX-standard sh
, in modern descendants) scripts with a smaller memory footprint than its counterpart, Bash. Its use tends to expose bashisms – bash-centric assumptions made in scripts meant to run on sh.
The Bourne shell was once standard on all branded Unix systems, although historically BSD-based systems had many scripts written in csh. As the basis of POSIX sh
syntax, Bourne shell scripts can typically be run with Bash or dash on Linux or other Unix-like systems.
Bash, short for Bourne-Again SHell, is a shell program and command language supported by the Free Software Foundation and first developed for the GNU Project by Brian Fox. Designed as a 100% free software alternative for the Bourne shell, it was initially released in 1989. Its moniker is a play on words, referencing both its predecessor, the Bourne shell, and the concept of renewal.
KornShell (ksh
) is a Unix shell which was developed by David Korn at Bell Labs in the early 1980s and announced at USENIX on July 14, 1983. The initial development was based on Bourne shell source code. Other early contributors were Bell Labs developers Mike Veach and Pat Sullivan, who wrote the Emacs and vi-style line editing modes' code, respectively. KornShell is backward-compatible with the Bourne shell and includes many features of the C shell, inspired by the requests of Bell Labs users.
A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text. A script which sets up the environment, runs the program, and does any necessary cleanup or logging, is called a wrapper.
A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system to control the execution of the system using shell scripts.
The C shell is a Unix shell created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been widely distributed, beginning with the 2BSD release of the Berkeley Software Distribution (BSD) which Joy first distributed in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp.
tcsh is a Unix shell based on and backward compatible with the C shell (csh
).
Almquist shell is a lightweight Unix shell originally written by Kenneth Almquist in the late 1980s. Initially a clone of the System V.4 variant of the Bourne shell, it replaced the original Bourne shell in the BSD versions of Unix released in the early 1990s.
Unix System V is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, and 4. System V Release 4 (SVR4) was commercially the most successful version, being the result of an effort, marketed as Unix System Unification, which solicited the collaboration of the major Unix vendors. It was the source of several common commercial Unix features. System V is sometimes abbreviated to SysV.
bc, for basic calculator, is "an arbitrary-precision calculator language" with syntax similar to the C programming language. bc is typically used as either a mathematical scripting language or as an interactive mathematical shell.
A command shell is a command-line interface to interact with and manipulate a computer's operating system.
In computing, alias is a command in various command-line interpreters (shells), which enables a replacement of a word by another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. alias
is available in Unix shells, AmigaDOS, 4DOS/4NT, FreeDOS, KolibriOS, Windows PowerShell, ReactOS, and the EFI shell. Aliasing functionality in the MS-DOS and Microsoft Windows operating systems is provided by the DOSKey command-line utility.
In computing, a shebang is the character sequence consisting of the characters number sign and exclamation mark at the beginning of a script. It is also called sharp-exclamation, sha-bang, hashbang, pound-bang, or hash-pling.
In Unix and Unix-like operating systems, job control refers to control of jobs by a shell, especially interactively, where a "job" is a shell's representation for a process group. Basic job control features are the suspending, resuming, or terminating of all processes in the job/process group; more advanced features can be performed by sending signals to the job. Job control is of particular interest in Unix due to its multiprocessing, and should be distinguished from job control generally, which is frequently applied to sequential execution.
getopts
is a built-in Unix shell command for parsing command-line arguments. It is designed to process command line arguments that follow the POSIX Utility Syntax Guidelines, based on the C interface of getopt.
The script command is a Unix utility that records a terminal session. It dates back to the 1979 3.0 Berkeley Software Distribution (BSD).
In a Unix shell, the full stop called the dot command (.) is a command that evaluates commands in a computer file in the current execution context. In the C shell, a similar functionality is provided as the source
command, and this name is seen in "extended" POSIX shells as well.
The restricted shell is a Unix shell that restricts some of the capabilities available to an interactive user session, or to a shell script, running within it. It is intended to provide an additional layer of security, but is insufficient to allow execution of entirely untrusted software. A restricted mode operation is found in the original Bourne shell and its later counterpart Bash, and in the KornShell. In some cases a restricted shell is used in conjunction with a chroot jail, in a further attempt to limit access to the system as a whole.
In computing, command substitution is a facility that allows a command to be run and its output to be pasted back on the command line as arguments to another command. Command substitution first appeared in the Bourne shell, introduced with Version 7 Unix in 1979, and has remained a characteristic of all later Unix shells. The feature has since been adopted in other programming languages as well, including Perl, PHP, Ruby and Microsoft's Powershell under Windows. It also appears in Microsoft's CMD.EXE in the FOR
command and the ( )
command.
A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternative to the non-interactive interface available with punched cards.
Instead of inventing a new script language, we built a form entry system by modifying the Bourne shell, adding built-in commands as necessary.
This section's use of external links may not follow Wikipedia's policies or guidelines.(August 2016) |