Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Bourne shell
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Command-line interpreter for operating systems}} {{Use dmy dates|date=July 2021}} {{distinguish|text=the [[Bash (Unix shell)|Bourne-Again Shell]]}} {{Infobox software | name = Bourne shell | logo = <!-- [[File: ]] --> | screenshot = File:Version 7 UNIX SIMH PDP11 Kernels Shell.png | caption = Bourne shell interaction on [[Version 7 Unix]] | collapsible = | author = [[Stephen R. Bourne|Stephen Bourne]] | developer = [[Bell Telephone Laboratories]] | released = {{Start date and age|1979}} | discontinued = | latest release version = | latest release date = <!-- {{start date and age|YYYY|MM|DD}} --> | latest preview version = | latest preview date = <!-- {{start date and age|YYYY|MM|DD}} --> | programming language = | operating system = [[Unix]] | platform = | size = | language = | genre = [[Unix shell]] | website = | license = {{under discussion inline|License}} }} The '''Bourne shell''' ('''<code>sh</code>''') is a [[Shell (computing)|shell]] [[Command-line interface#Command-line interpreter|command-line interpreter]] for computer [[operating system]]s. It first appeared on [[Version 7 Unix]], as its default [[Unix shell|shell]]. [[Unix-like]] systems continue to have <code>/bin/sh</code>—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. The Bourne shell was once standard on all branded [[Unix]] systems, although historically [[BSD]]-based systems had many scripts written in [[C shell|csh]]. As the basis of [[POSIX]] <code>sh</code> syntax, Bourne shell scripts can typically be run with [[Bash (Unix shell)|Bash]] or [[Debian Almquist shell|dash]] on [[Linux]] or other Unix-like systems; Bash itself is a [[Free software|free]] clone of Bourne. ==History== [[File:Version 7 UNIX SIMH PDP11 Bourne Shell Manual.png|thumb|[[Version 7 Unix]]: the original Bourne shell [[man page|manual page]]. [[PDP-11]] simulation with [[SIMH]]]] ===Origins=== Work on the Bourne shell initially started in 1976.<ref>https://www.bsdcan.org/2015/schedule/events/612.en.html Stephen Bourne Keynote for BSDCan 2015</ref> Developed by [[Stephen R. Bourne|Stephen Bourne]] at [[Bell Labs]], it was a replacement for the [[Thompson shell]], whose executable file had the same name—<code>sh</code>. The Bourne shell was also preceded by the [[PWB shell|Mashey shell]]. Bourne 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.{{Citation needed|date=December 2024}} Some of the primary goals of the shell were:<ref>{{cite web|url=http://www.computerworld.com.au/article/279011/-z_programming_languages_bourne_shell_sh|title=The A-Z of Programming Languages: Bourne shell, or sh|website=computerworld.com.au|access-date=6 March 2009|archive-url=https://web.archive.org/web/20100111203059/http://www.computerworld.com.au/article/279011/-z_programming_languages_bourne_shell_sh|archive-date=11 January 2010|url-status=dead}}</ref> * To allow [[shell script]]s to be used as [[filter (software)|filters]]. * To provide programmability including [[control flow]] and [[Variable (computer science)|variables]]. * Control over all input/output [[file descriptor]]s. * Control over [[Unix signal|signal handling]] within scripts. * No limits on string lengths when interpreting shell scripts. * Rationalize and generalize string quoting mechanism. * The [[environment variable|environment mechanism]]. This allowed context to be established at startup and provided a way for shell scripts to pass context to sub scripts ([[Process (computing)|processes]]) without having to use explicit [[parameter (computer science)|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]]: <code>`command`</code>. * [[Here documents]] using <code><<</code> to embed a block of input text within a script. * <code>for ~ do ~ done</code> loops, in particular the use of <code>$*</code> to loop over arguments, as well as <code>for ~ in ~ do ~ done</code> loops for iterating over lists. * <code>case ~ in ~ esac</code> selection mechanism, primarily intended to assist [[argument parsing]]. * <code>sh</code> provided support for environment variables using keyword parameters and exportable variables. * Contains strong provisions for controlling input and output and in its [[regular expression|expression matching]] facilities. The Bourne shell also was the first to feature the convention of using [[file descriptor]] <code>2></code> for [[error message]]s, 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<ref name="reader">{{cite tech report |first1=M. D. |last1=McIlroy |author-link1=Doug McIlroy |year=1987 |url=http://www.cs.dartmouth.edu/~doug/reader.pdf |archive-url=https://web.archive.org/web/20140504225225/http://www.cs.dartmouth.edu/~doug/reader.pdf |archive-date=2014-05-04 |url-status=live |title=A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 |series=CSTR |number=139 |institution=Bell Labs}}</ref> that he had been working on at [[University of Cambridge|Cambridge University]]. In addition to the style in which the program was written, Bourne reused portions of [[ALGOL 68]]'s <code>'''if''' ~ '''then''' ~ '''elif''' ~ '''then''' ~ '''else''' ~ '''fi'''</code>, <code>'''case''' ~ '''in''' ~ '''esac'''</code> and <code>'''for'''/'''while''' ~ '''do''' ~ '''od'''</code>" (using <code>done</code> instead of <code>'''od'''</code>) clauses in the common [[Unix]] Bourne shell syntax. Moreover, – although the v7 shell is written in [[C (programming language)|C]] – Bourne took advantage of some [[Macro (computer science)|macros]]<ref>{{Cite web| url=http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh/mac.h|title=mac.h – Macros used by Bourne to structure C like Algol68C |access-date=9 September 2006|author=Bourne, Steve|author-link=Stephen R. Bourne|date= 12 January 1979 |publisher=[[AT&T Corporation]] }}</ref> to give the C [[source code]] an ALGOL 68 flavor. These macros (along with the [[Finger protocol|finger]] command distributed in Unix version [[Berkeley Software Distribution#4.2BSD|4.2BSD]]) inspired the [[International Obfuscated C Code Contest]] (IOCCC).<ref>{{Cite web|url=http://www.ioccc.org/faq.html|title=The IOCCC FAQ – Q/A: How did the IOCCC get started?| access-date=9 September 2006|author=Landon Curt Noll|author-link=Landon Curt Noll|author2=Simon Cooper|author3=Peter Seebach|author4=Leonid A. Broukhis|name-list-style=amp|year= 2004|publisher=ioccc.org}}</ref> ===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.<ref>{{cite web|url=http://www.in-ulm.de/~mascheck/various/whatshell/|title=what shell is this|website=www.in-ulm.de}}</ref> Features of the Bourne shell versions since 1979 include:<ref>{{cite web|url=http://www.in-ulm.de/~mascheck/bourne/|title=traditional Bourne shell family / history and development|website=www.in-ulm.de}}</ref> * Built-in {{code|test}} command – System III shell (1981) * # as comment character – System III shell (1981) * Colon in parameter substitutions "${parameter:=word}" – System III shell (1981) * {{code|continue}} with argument – System III shell (1981) * {{code|cat <<-EOF}} for indented here documents – System III shell (1981) * Functions and the {{code|return}} builtin – SVR2 shell (1984) * Built-ins {{code|unset}}, {{code|echo}}, {{code|type}} – SVR2 shell (1984) * Source code de-ALGOL68-ized – SVR2 shell (1984) * Modern "{{code|$@}}" – SVR3 shell (1986) * Built-in {{code|getopts}} – 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]] uses a 1978 snapshot of Bourne Shell "VERSION sys137 DATE 1978 Oct 12 22:39:57".{{citation needed|date=January 2017}} The DMERT shell runs on [[3B21D]] computers still in use in the telecommunications industry.{{citation needed|date=January 2017}} ===Korn shell=== {{Main|Korn shell}} [[File:OpenBSD ksh Interaction.png|thumb|Interaction with ''[[Korn shell|pdksh]]'' in [[OpenBSD]] (default shell)]] The Korn shell (ksh) written by [[David Korn (computer scientist)|David Korn]] based on the original Bourne Shell source code,<ref> {{citation | title = ksh - An Extensible High Level Language | last = Korn | first = David G. | publisher = USENIX Association | journal=Proceedings of the USENIX 1994 Very High Level Languages Symposium | date = 26 October 1994 | url = https://www.usenix.org/legacy/publications/library/proceedings/vhll/full_papers/korn.ksh.a | quote = Instead of inventing a new script language, we built a form entry system by modifying the Bourne shell, adding built-in commands as necessary. | access-date = 5 February 2015 }}</ref> 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 (Unix)|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 distribution]]s. A clone of ksh88 known as [[Korn shell|pdksh]] is the default shell in OpenBSD. ===Schily Bourne Shell=== [[Jörg Schilling]]'s Schily-Tools includes three Bourne Shell derivatives.<ref>{{cite web |title=Schily Bourne Shell - A modern enhanced and POSIX compliant Bourne Shell source maintained by Jörg Schilling. |url=http://schilytools.sourceforge.net/bosh.html |website=Schily-Tools |access-date=26 May 2020 |archive-date=27 September 2019 |archive-url=https://web.archive.org/web/20190927190016/http://schilytools.sourceforge.net/bosh.html |url-status=dead }}</ref> ==Relationship to other shells== ===C shell=== {{Main|C shell}} [[Bill Joy]], the author of the C shell, criticized the Bourne shell as being unfriendly for interactive use,<ref>[http://www.kitebird.com/csh-tcsh-book/csh-intro.pdf ''An Introduction to the C shell''] {{Webarchive|url=https://web.archive.org/web/20180713012111/http://www.kitebird.com/csh-tcsh-book/csh-intro.pdf |date=13 July 2018 }} by [[Bill Joy]].{{Page needed|date=July 2017}}</ref> 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,<ref name="bourne198310">{{cite news | url=https://archive.org/stream/byte-magazine-1983-10/1983_10_BYTE_08-10_UNIX#page/n187/mode/2up | title=The Unix Shell | work=BYTE | date=October 1983 | access-date=30 January 2015 | author=Bourne, Stephen R. | pages=187}}</ref> and [[Tom Christiansen]] also criticized C shell as being unsuitable for scripting and programming.<ref>{{cite web|url=http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/|title=Csh Programming Considered Harmful|author=Tom Christiansen|date=28 September 1995|access-date=17 February 2014}}</ref> ===Almquist shells=== {{Main|Almquist shell}} Due to copyright issues surrounding the Bourne Shell as it was used in historic [[Computer Systems Research Group|CSRG]] BSD releases, Kenneth Almquist developed a clone of the Bourne Shell, known by some as the Almquist shell and available under the [[BSD licenses|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 [[Almquist shell#Dash|Debian Almquist shell]], or dash. This shell provides faster execution of standard <code>sh</code> (and POSIX-standard <code>sh</code>, in modern descendants) scripts with a smaller [[memory footprint]] than its counterpart, Bash. Its use tends to expose [[Bash (Unix shell)#Portability|bashisms]] – bash-centric assumptions made in scripts meant to run on sh. ===Other shells=== * [[Bash (Unix shell)|Bash]] (the ''Bourne-Again shell'') was developed in 1989 for the [[GNU|GNU project]] and incorporates features from the Bourne shell, csh, and ksh. It is meant to be POSIX-compliant. * [[Rc (Unix shell)|rc]] was created at [[Bell Labs]] by [[Tom Duff]] as a replacement for sh for [[Version 10 Unix]]. It is the default shell for [[Plan 9 from Bell Labs]]. It has been ported to UNIX as part of [[Plan 9 from User Space]]. * [[Z shell]], developed by Paul Falstad in 1990, is an extended Bourne shell with a large number of improvements, including some features of [[Bash (Unix shell)|Bash]], [[KornShell|ksh]], and [[tcsh]]. ==See also== * [[Comparison of command shells]] * [[Unix shell]] ==References== {{Reflist}} ==External links== {{External links|section|date=August 2016}} {{Wikibooks|Bourne Shell Scripting}} * [http://www.in-ulm.de/~mascheck/bourne/ The individual members of "The Traditional Bourne Shell Family"] * [http://www.in-ulm.de/~mascheck/bourne/common.html "Characteristical common properties of the traditional Bourne shells"] * [http://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] * [http://steve-parker.org/sh/bourne.shtml Original Bourne Shell documentation from 1978] * [http://heirloom.sourceforge.net/sh.html A port of the "heirloom" SVR4 Bourne shell from OpenSolaris to some other Unix-like systems] * [https://web.archive.org/web/20191030202653/http://www.unix.org/whitepapers/shdiffs.html Migrating from the System V (SVR4) Shell to the POSIX Shell] * [http://www.grymoire.com/Unix/Sh.html Bourne Shell Tutorial (syntax)] * [http://www.faqs.org/faqs/unix-faq/shell/shell-differences/ Faqs shell differences] * [http://www.computerworld.com.au/article/279011/-z_programming_languages_bourne_shell_sh?fp=&fpid=&pf=1 Howard Dahdah, The A–Z of Programming Languages: Bourne shell, or sh – An in-depth interview with Steve Bourne, creator of the Bourne shell, or sh], ''[[Computerworld]]'', 5 March 2009. {{Unix Shells}} {{DEFAULTSORT:Bourne Shell}} [[Category:1979 software]] [[Category:POSIX]] [[Category:Scripting languages]] [[Category:Text-oriented programming languages]] [[Category:Unix shells]] [[Category:Unix SUS2008 utilities]] [[de:Unix-Shell#Die Bourne-Shell]]
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Citation
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite news
(
edit
)
Template:Cite tech report
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Distinguish
(
edit
)
Template:External links
(
edit
)
Template:Infobox software
(
edit
)
Template:Main
(
edit
)
Template:Page needed
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Unix Shells
(
edit
)
Template:Use dmy dates
(
edit
)
Template:Webarchive
(
edit
)
Template:Wikibooks
(
edit
)
Search
Search
Editing
Bourne shell
Add topic