Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Thompson shell
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|Unix command interpreter}} {{Infobox software | name = Thompson shell | logo = <!-- [[File: ]] --> | screenshot = <!-- [[File: ]] --> | caption = | collapsible = | author = [[Ken Thompson (computer programmer)|Ken Thompson]] | developer = [[AT&T Bell Laboratories]] | released = {{Start date and age|1971|11|3}}<!-- {{start date|1971|MM|DD}} --> | 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]] and [[Unix-like]] | platform = | size = | language = | genre = [[Unix shell]] | license = | website = }} The '''Thompson shell''' was the first [[Unix shell]], introduced in the first version of [[Unix]] in 1971, and was written by [[Ken Thompson]].<ref name=Mashey1976-10-13> {{cite conference | url = https://grosskurth.ca/bib/1976/mashey-command.pdf | title = Using a Command Language as a High-Level Programming Language | conference = 2nd International Conference on Software Engineering | author = [[J. R. Mashey]] | date = 1976-10-13 | pages = 169–176 }} </ref> It was a simple command interpreter, not designed for scripting, but nonetheless introduced several innovative features to the [[command-line interface]] and led to the development of the later Unix shells. ==History== The name "shell" for a [[Command-line interface#Command-line interpreter|command-line interpreter]] and the concept of making the shell a user program outside of the operating system [[Kernel (operating system)|kernel]] were introduced in Unix's precursor [[Multics]]. An early feature of the Thompson shell was a compact syntax for input/output [[Redirection (computing)|redirection]]. In Multics, redirecting the input or output of a command required separate commands to start and stop redirection; in Unix, one could simply add an argument to the command line consisting of the < symbol followed by a filename for input or the > symbol for output, and the shell would redirect I/O for the duration of the command. This syntax was already present by the release of the first version of Unix in 1971. A later addition was the concept of [[pipeline (Unix)|pipes]]. At the suggestion of [[Douglas McIlroy]], the redirection syntax was expanded so that the output of one command could be passed to the input of another command. The original pipe syntax, as described in the Version 3 manual, was: command1 >command2> This syntax proved too ambiguous and was easily confused with redirection to files—the system cannot tell whether "command2" is a command or a file.{{Citation needed|reason=this statement makes no sense. Ken Thompson was no novice programmer. The syntax must have been sufficiently clear to the interpreter. The syntax shown *does* look unambiguous (but hard to read for humans). More likely, it was confusing for users. A citation will settle this.|date=November 2024}} By Version 4, the syntax had changed to use both the | and ^ symbols to denote pipes: command1 | command2 This produces exactly the same result as: command1 ^ command2 The > symbol changed into: command1 > file1 This would put the output of command1 into file1. The Thompson shell syntax for redirection with < and >, and piping with |, has proven durable and has been adopted by most other Unix shells and command shells of several other operating systems, most notably on [[DOS]], [[OS/2]] and [[Microsoft Windows]]. == Design == The shell's design was intentionally minimalistic; even the ''if'' and ''goto'' statements, essential for control of program flow, were implemented as separate commands.<ref name=Mashey1976-10-13/> The shell has no facilities for comments besides a builtin command {{code|:}}. Programmers simply write text after this command, which ignores all parameters and simply succeeds. Other builtins include {{code|chdir}}, {{code|exit}}, {{code|login}}, {{code|newgrp}}, {{code|shift}}, and {{code|wait}}.<ref name=etsh.man/> The ''if'' command combines the uses of modern-day Bourne shell ''test'' and ''if''. The command first looks for an expression (which can be similar to modern-day ''test'' or involve an external command) then treats the rest of the command-line as the command to execute if the condition turns out true. There is no ''else'' branch.<ref>{{cite web |title=if(1) (html) - IF(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_if.1.html |website=etsh.nl}}</ref> ''goto'' is implemented in an interesting way, as it is separate from the shell. When asked to jump to "LABEL", it seeks the current command file for a line that says {{code|: LABEL}} (recall that {{code|:}} is simply ignored), then exits. When the shell tries to read a next line, the repositioned file descriptor will direct it to the labelled location.<ref>{{cite web |title=goto(1) (html) - GOTO(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_goto.1.html |website=etsh.nl}}</ref> There is no redirection of additional file descriptors other than standard input and output (0 and 1) in Thompson shell. Redirection of stderr (file descriptor 2) also requires an external program wrapper, {{code|fd2}}.<ref>{{cite web |title=fd2(1) (html) - FD2(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_fd2.1.html |website=etsh.nl}}</ref> The shell supports globbing,<ref name=etsh.man>{{cite web |title=tsh(1) (html) - TSH(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_tsh.1.html |website=etsh.nl}}</ref> but actually implements it by deferring it to a {{code|glob}} command that replaces the arguments and calls the requested command.<ref>{{cite web |title=glob(1) (html) - GLOB(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_glob.1.html |website=etsh.nl}}</ref> Thompson shell has positional parameters, but no named variables nor access to environmental variables. It understands the creation of background commands with {{code|&}}, similar to Bourne shell. It offers quoting and backslash escapes, though the single quotes work differently from Bourne shell.<ref name=etsh.man/> ==Decline and replacements== As a result of the simplistic design, by the 1975 release of [[Version 6 Unix]], it was becoming clear that the Thompson shell was inadequate for most serious programming tasks. At this time, the developers of the [[PWB/UNIX|Programmer's Workbench UNIX]] distribution, most notably [[John Mashey]], began modifying the Thompson shell to make it more suitable for programming.<ref name=Mashey1976-10-13/> The result, known as the [[PWB shell]] or the Mashey shell, included more advanced flow-control mechanisms and introduced shell variables, but remained limited by the necessity to remain compatible with the Thompson shell. Finally, the Thompson shell was replaced as the main Unix shell by the [[Bourne shell]] in [[Version 7 Unix]] and the [[C shell]] in [[Berkeley Software Distribution#2BSD .28PDP-11.29|2BSD]], both released in 1979. Since virtually all modern Unix and [[Unix-like]] systems are descended from V7 and 2BSD, the Thompson shell is generally no longer used. It is, however, available as [[open-source software|open-source]] as part of several [[Ancient UNIX|Ancient Unix]] source distributions, and has been ported to modern Unices as a historical exhibit. ==See also== * [[Comparison of command shells]] ==References== {{Reflist}} ==External links== *[http://man.cat-v.org/unix-1st/1/sh Manual page for the Thompson shell in Unix 1st Edition]. *[https://www.bell-labs.com/usr/dmr/www/hist.html The Evolution of the Unix Time-Sharing System] - describes the early development of the shell *[http://www.in-ulm.de/~mascheck/bourne/index.html#origins Origins of the Bourne shell] - manual pages for the 3rd, 4th, and 6th edition Thompson shells, and other resources on the early shells *[https://etsh.nl/ Etsh (V6Sh) Project] - the Thompson shell and its associated utilities ported to modern Unix systems (plus an backwards-compatible "enhanced version" with some modern features) {{Unix Shells}} {{Ken Thompson navbox}} [[Category:Unix shells]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation needed
(
edit
)
Template:Cite conference
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Ken Thompson navbox
(
edit
)
Template:Main other
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Template other
(
edit
)
Template:Unix Shells
(
edit
)