Thompson Shell
   HOME

TheInfoList



OR:

The Thompson shell was the first
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 ...
, introduced in the first version of
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 ...
in 1971, and was written by
Ken Thompson Kenneth Lane Thompson (born February 4, 1943) is an American pioneer of computer science. Thompson worked at Bell Labs for most of his career where he designed and implemented the original Unix operating system. He also invented the B (programmi ...
. It was a simple command interpreter, not designed for scripting, but nonetheless introduced several innovative features to the
command-line interface A command-line interface (CLI) is a means of interacting with software via command (computing), commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user ...
and led to the development of the later Unix shells.


History

The name "shell" for a
command-line interpreter A command-line interface (CLI) is a means of interacting with software via commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternativ ...
and the concept of making the shell a user program outside of the operating system kernel were introduced in Unix's precursor
Multics Multics ("MULTiplexed Information and Computing Service") is an influential early time-sharing operating system based on the concept of a single-level memory.Dennis M. Ritchie, "The Evolution of the Unix Time-sharing System", Communications of t ...
. An early feature of the Thompson shell was a compact syntax for input/output 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
pipes Pipe(s), PIPE(S) or piping may refer to: Objects * Pipe (fluid conveyance), a hollow cylinder following certain dimension rules ** Piping, the use of pipes in industry * Smoking pipe ** Tobacco pipe * Half-pipe and quarter pipe, semi-circu ...
. At the suggestion of
Douglas McIlroy Malcolm Douglas McIlroy (born 1932) is an American mathematician, engineer, and programmer. As of 2019 he is an Adjunct Professor of Computer Science at Dartmouth College. McIlroy is best known for having originally proposed Unix pipelines and de ...
, 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. 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 DOS (, ) is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible syste ...
,
OS/2 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
and
Microsoft Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
.


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. The shell has no facilities for comments besides a builtin command . Programmers simply write text after this command, which ignores all parameters and simply succeeds. Other builtins include , , , , , and . 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. ''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 (recall that 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. 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, . The shell supports globbing, but actually implements it by deferring it to a command that replaces the arguments and calls the requested command. Thompson shell has positional parameters, but no named variables nor access to environmental variables. It understands the creation of background commands with , similar to Bourne shell. It offers quoting and backslash escapes, though the single quotes work differently from Bourne shell.


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 Programmer's Workbench UNIX distribution, most notably John Mashey, began modifying the Thompson shell to make it more suitable for programming. 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 The Bourne shell (sh) is a shell command-line interpreter for computer operating systems. It first appeared on Version 7 Unix, as its default shell. Unix-like systems continue to have /bin/sh—which will be the Bourne shell, or a symbolic lin ...
in
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 ...
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 ...
in
2BSD The history of the Berkeley Software Distribution began in the 1970s when University of California, Berkeley received a copy of Unix. Professors and students at the university began adding software to the operating system and released it as BSD to ...
, both released in 1979. Since virtually all modern Unix and
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 are descended from V7 and 2BSD, the Thompson shell is generally no longer used. It is, however, available as
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
as part of several
Ancient Unix Ancient history is a time period from the beginning of writing and recorded human history through late antiquity. The span of recorded history is roughly 5,000 years, beginning with the development of Sumerian cuneiform script. Ancient hi ...
source distributions, and has been ported to modern Unices as a historical exhibit.


See also

*
Comparison of command shells This article catalogs comparable aspects of notable operating system shell (computing), shells. General characteristics {, class="wikitable sortable sticky-header sort-under" style="width: auto; text-align: center; font-size: smaller;" , - ...


References


External links


Manual page for the Thompson shell in Unix 1st Edition


- describes the early development of the shell

- manual pages for the 3rd, 4th, and 6th edition Thompson shells, and other resources on the early shells
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) {{Ken Thompson navbox Unix shells