HOME

TheInfoList



OR:

The Bourne shell (sh) is a
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses Science Biology * Seashell, a hard outer layer of a marine ani ...
command-line interpreter for computer
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
s. It first appeared on
Version 7 Unix Version 7 Unix, also called Seventh Edition Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commerc ...
, as its default
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses Science Biology * Seashell, a hard outer layer of a marine ani ...
.
Unix-like A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
systems continue to have /bin/sh—which will be the Bourne shell, or a
symbolic link In computing, a symbolic link (also symlink or soft link) is a file whose purpose is to point to a file or directory (called the "target") by specifying a path thereto. Symbolic links are supported by POSIX and by most Unix-like operating syste ...
or
hard link In computing, a hard link is a directory entry (in a Directory (computing), directory-based file system) that associates a name with a Computer file, file. Thus, each file must have at least one hard link. Creating additional hard links for a fil ...
to a compatible shell—even when other shells are used by most users. The Bourne shell was once standard on all branded
Unix Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
systems, although historically
BSD The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginni ...
-based systems had many scripts written in csh. As the basis of
POSIX The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
sh syntax, Bourne shell scripts can typically be run with Bash or
dash The dash is a punctuation mark consisting of a long horizontal line. It is similar in appearance to the hyphen but is longer and sometimes higher from the baseline. The most common versions are the endash , generally longer than the hyphen ...
on
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
or other Unix-like systems; Bash itself is a free clone of Bourne.


History


Origins

Work on the Bourne shell initially started in 1976. Developed by Stephen Bourne at
Bell Labs Nokia Bell Labs, commonly referred to as ''Bell Labs'', is an American industrial research and development company owned by Finnish technology company Nokia. With headquarters located in Murray Hill, New Jersey, Murray Hill, New Jersey, the compa ...
, it was a replacement for the Thompson shell, whose executable file had the same name—sh. The Bourne shell was also preceded by the Mashey shell. Bourne was released in 1979 in the
Version 7 Unix Version 7 Unix, also called Seventh Edition Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commerc ...
release distributed to colleges and universities. Although it is used as an interactive command interpreter, it was also intended as a
scripting language In computing, a script is a relatively short and simple set of instructions that typically automation, automate an otherwise manual process. The act of writing a script is called scripting. A scripting language or script language is a programming ...
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 Brian Wilson Kernighan (; born January 30, 1942) is a Canadian computer scientist. He worked at Bell Labs and contributed to the development of Unix alongside Unix creators Ken Thompson and Dennis Ritchie. Kernighan's name became widely known ...
and
Rob Pike Robert Pike (born 1956) is a Canadian programmer and author. He is best known for his work on the Go programming language while working at Google and the Plan 9 operating system while working at Bell Labs, where he was a member of the Unix t ...
—the first commercially published book that presented the shell as a programming language in a tutorial form. Some of the primary goals of the shell were: * To allow
shell script 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 command languages. Typical operations performed by shell scripts include file manipu ...
s to be used as
filters Filtration is a physical process that separates solid matter and fluid from a mixture. Filter, filtering, filters or filtration may also refer to: Science and technology Computing * Filter (higher-order function), in functional programming * Fil ...
. * To provide programmability including
control flow In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an '' ...
and variables. * Control over all input/output
file descriptor In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket. File descriptors typically h ...
s. * Control over signal handling within scripts. * No limits on string lengths when interpreting shell scripts. * Rationalize and generalize string quoting mechanism. * The environment mechanism. This allowed context to be established at startup and provided a way for shell scripts to pass context to sub scripts ( processes) without having to use explicit positional parameters.


Features of the original version

Features of the Version 7 UNIX Bourne shell include: * Scripts can be invoked as commands by using their filename * May be used interactively or non-interactively * Allows both synchronous and asynchronous execution of commands * Supports input and output redirection and pipelines * Provides a set of built-in commands * Provides flow control constructs and quotation facilities. * Typeless variables * Provides local and global variable scope * Scripts do not require compilation before execution * Does not have a goto facility, so code restructuring may be necessary * Command substitution using backquotes: `command`. * Here documents using << 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. * Contains strong provisions for controlling input and output and in its expression matching facilities. The Bourne shell also was the first to feature the convention of using
file descriptor In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket. File descriptors typically h ...
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 that he had been working on at
Cambridge University The University of Cambridge is a Public university, public collegiate university, collegiate research university in Cambridge, England. Founded in 1209, the University of Cambridge is the List of oldest universities in continuous operation, wo ...
. In addition to the style in which the program was written, Bourne reused portions of
ALGOL 68 ALGOL 68 (short for ''Algorithmic Language 1968'') is an imperative programming language member of the ALGOL family that was conceived as a successor to the ALGOL 60 language, designed with the goal of a much wider scope of application and ...
'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 Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
Bourne shell syntax. Moreover, – although the v7 shell is written in C – Bourne took advantage of some macros to give the C
source code In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer. Since a computer, at base, only ...
an ALGOL 68 flavor. These macros (along with the
finger A finger is a prominent digit (anatomy), digit on the forelimbs of most tetrapod vertebrate animals, especially those with prehensile extremities (i.e. hands) such as humans and other primates. Most tetrapods have five digits (dactyly, pentadact ...
command distributed in Unix version 4.2BSD) inspired the
International Obfuscated C Code Contest The International Obfuscated C Code Contest (abbreviated IOCCC) is a computer programming contest for Source code, code written in C (programming language), C that is the most creatively obfuscated code, obfuscated. Held semi-annually, it is desc ...
(IOCCC).


Features introduced after 1979

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. Features of the Bourne shell versions since 1979 include: * Built-in command – System III shell (1981) * # as comment character – System III shell (1981) * Colon in parameter substitutions "$" – System III shell (1981) * with argument – System III shell (1981) * for indented here documents – System III shell (1981) * Functions and the builtin – SVR2 shell (1984) * Built-ins , , – SVR2 shell (1984) * Source code de-ALGOL68-ized – SVR2 shell (1984) * Modern "" – SVR3 shell (1986) * Built-in – SVR3 shell (1986) * Cleaned up parameter handling allows recursively callable functions – SVR3 shell (1986) * 8-bit clean – SVR3 shell (1986) * Job control – SVR4 shell (1989) * Multi-byte support – SVR4 shell (1989)


Variants


DMERT shell

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 Naperville ( ) is a city in DuPage County, Illinois, DuPage and Will County, Illinois, Will counties in the U.S. state of Illinois. It is a southwestern suburb of Chicago located west of the city on the DuPage River. As of the 2020 United State ...
uses a 1978 snapshot of Bourne Shell "VERSION sys137 DATE 1978 Oct 12 22:39:57". The DMERT shell runs on 3B21D computers still in use in the telecommunications industry.


Korn shell

The Korn shell (ksh) written by David Korn based on the original Bourne Shell source code, was a middle road between the Bourne shell and the
C shell The C shell (csh or the improved version, tcsh) 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 ...
. 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 The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
shell standard. A newer version, ksh93, has been open source since 2000 and is used on some
Linux distribution A Linux distribution, often abbreviated as distro, is an operating system that includes the Linux kernel for its kernel functionality. Although the name does not imply product distribution per se, a distro—if distributed on its own—is oft ...
s. A clone of ksh88 known as pdksh is the default shell in OpenBSD.


Schily Bourne Shell

Jörg Schilling's Schily-Tools includes three Bourne Shell derivatives.


Relationship to other shells


C shell

Bill Joy William Nelson Joy (born November 8, 1954) is an American computer engineer and venture capitalist. He co-founded Sun Microsystems in 1982 along with Scott McNealy, Vinod Khosla, and Andy Bechtolsheim, and served as Chief Scientist and CTO ...
, the author of the C shell, criticized the Bourne shell as being unfriendly for interactive use, 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, and Tom Christiansen also criticized C shell as being unsuitable for scripting and programming.


Almquist shells

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 BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD lic ...
, 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 Memory footprint refers to the amount of main memory that a program uses or references while running. The word footprint generally refers to the extent of physical dimensions that an object occupies, giving a sense of its size. In computing, t ...
than its counterpart, Bash. Its use tends to expose bashisms – bash-centric assumptions made in scripts meant to run on sh.


Other shells

* Bash (the ''Bourne-Again shell'') was developed in 1989 for the
GNU project The GNU Project ( ) is a free software, mass collaboration project announced by Richard Stallman on September 27, 1983. Its goal is to give computer users freedom and control in their use of their computers and Computer hardware, computing dev ...
and incorporates features from the Bourne shell, csh, and ksh. It is meant to be POSIX-compliant. * rc was created at
Bell Labs Nokia Bell Labs, commonly referred to as ''Bell Labs'', is an American industrial research and development company owned by Finnish technology company Nokia. With headquarters located in Murray Hill, New Jersey, Murray Hill, New Jersey, the compa ...
by Tom Duff as a replacement for sh for Version 10 Unix. It is the default shell for
Plan 9 from Bell Labs Plan 9 from Bell Labs is a distributed operating system which originated from the Computing Science Research Center (CSRC) at Bell Labs in the mid-1980s and built on UNIX concepts first developed there in the late 1960s. Since 2000, Plan 9 has ...
. It has been ported to UNIX as part of Plan 9 from User Space. *
Z shell The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh. Zsh w ...
, developed by Paul Falstad in 1990, is an extended Bourne shell with a large number of improvements, including some features of Bash, ksh, and tcsh.


See also

* Comparison of command shells *
Unix shell A Unix shell is a Command-line_interface#Command-line_interpreter, command-line interpreter or shell (computing), shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command languag ...


References


External links


The individual members of "The Traditional Bourne Shell Family"


* ttp://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh Historical C source code for the Bourne shell using mac.h macros from 1979 {{DEFAULTSORT:Bourne Shell 1979 software POSIX Scripting languages Text-oriented programming languages Unix shells Unix SUS2008 utilities de:Unix-Shell#Die Bourne-Shell