Bourne shell
From Free net encyclopedia
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.
Contents |
Origins
Among the main goals of the Bourne shell was to take advantage of two key features of Version 7 kernel:
- the much larger parameter (argument) lists, previously limited to 127 bytes and limited to 8192 bytes in Version 7.
- environment variables. These were a new feature of Version 7 and allowed a good deal of ancillary information to be passed to programs upon startup.
Notable features
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.
Although it is used as an interactive command interpreter, it was always intended as a scripting language. It gained popularity with the publication of The UNIX Programming Environment by Brian W. Kernighan and Rob Pike. This was the first commercially published book that presented the shell as a programming language in a tutorial form.
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 ALGOL 68's "if ~ then ~ else ~ fi
", "case ~ in ~ out ~ esac
" and "for ~ while ~ do ~ od
" clauses in the common Unix Bourne shell. 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.
Descendants
The C shell (csh) was distributed with 4.1BSD, and took advantage of job control features of the BSD kernel. Job control is the ability to stop a program interactively and then restart it later. It was for this reason that the C shell gained popularity as a command interpreter. The C shell used a more "C like" syntax for its programming features that was incompatible with the Bourne shell and purportedly an improvement.
The Korn shell (ksh) written much later by David Korn, was a middle road between these two shells, with syntax chiefly drawn from the Bourne shell and job control features drawn from the C shell.
Bash, also known as the Bourne-Again shell, was later developed for the GNU project and takes features from the Bourne shell, csh and ksh.
Kenneth Almquist developed a clone of the Bourne Shell, known as the Almquist Shell, which is in use today.
Usage
The Bourne shell is now standard on all current branded Unix systems, although historically BSD based systems had many scripts written in csh. Bourne shell scripts can typically be run with bash on Linux or other Unix-like systems.
After Sun released their OpenSolaris variant of the Bourne shell as Open Source, a port of this shell for free Unix flavours (interesting concerning portability and historic interests) has been made available by the Heirloom project.
The original inspiration of the International Obfuscated C Code Contest (IOCCC - which is a contest of worst coding practices) came from the Bourne Shell source and the finger command as distributed in Unix version 4.2BSD.
External links
- UNIX Shell Script Tutorials & Reference
- UNIX/Linux Bourne/Bash Shell Scripting Tutorial
- The individual members of "The Traditional Bourne Shell Family"
- Macros used by Bourne to structure C like Algol68C
- Actual C source code for the Bourne shell using mac.h macros
- Original Bourne Shell documentation from 1978
- The International Obfuscated C Code Contest FAQ Page
- A port of the "heirloom" Bourne shell from OpenSolaris to other Unix-like systems
Template:Major programming languages smallde:Bourne Shell eo:sh fr:Bourne shell it:Bourne shell ja:Bourne Shell ko:본_셸 ru:Bourne shell