Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Thompson shell

From Wikipedia, the free encyclopedia
Unix command interpreter
Thompson shell
Original authorKen Thompson
DeveloperAT&T Bell Laboratories
Initial releaseNovember 3, 1971; 54 years ago (1971-11-03)
Operating systemUnix andUnix-like
TypeUnix shell

TheThompson shell was the firstUnix shell, introduced in the first version ofUnix in 1971, and was written byKen Thompson.[1]It was a simple command interpreter, not designed for scripting, but nonetheless introduced several innovative features to thecommand-line interface and led to the development of the later Unix shells.

History

[edit]

The name "shell" for acommand-line interpreter and the concept of making the shell a user program outside of the operating systemkernel were introduced in Unix's precursorMultics.

An early feature of the Thompson shell was a compact syntax for input/outputredirection. 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 ofpipes. At the suggestion ofDouglas 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] 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 as well as other operating systems such asMS-DOS.

Design

[edit]

The shell's design was intentionally minimalistic; even theif andgoto statements, essential for control of program flow, were implemented as separate commands.[1]

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 includechdir,exit,login,newgrp,shift, andwait.[2]

Theif command combines the uses of modern-day Bourne shelltest andif. The command first looks for an expression (which can be similar to modern-daytest 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 noelse branch.[3]

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: LABEL (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.[4]

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,fd2.[5]

The shell supports globbing,[2] but actually implements it by deferring it to aglob command that replaces the arguments and calls the requested command.[6]

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.[2]

Decline and replacements

[edit]

As a result of the simplistic design, by the 1975 release ofVersion 6 Unix, it was becoming clear that the Thompson shell was inadequate for most serious programming tasks.

At this time, the developers of theProgrammer's Workbench UNIX distribution, most notablyJohn Mashey, began modifying the Thompson shell to make it more suitable for programming.[1]The result, known as thePWB 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 theBourne shell inVersion 7 Unix and theC shell in2BSD, both released in 1979. Since virtually all modern Unix andUnix-like systems are descended from V7 and 2BSD, the Thompson shell is generally no longer used. It is, however, available asopen-source as part of severalAncient Unix source distributions, and has been ported to modern Unices as a historical exhibit.

See also

[edit]

References

[edit]
  1. ^abcJ. R. Mashey (1976-10-13).Using a Command Language as a High-Level Programming Language(PDF). 2nd International Conference on Software Engineering. pp. 169–176.
  2. ^abc"tsh(1) (html) - TSH(1) - Manuals - Etsh Project (V6Shell)".etsh.nl.
  3. ^"if(1) (html) - IF(1) - Manuals - Etsh Project (V6Shell)".etsh.nl.
  4. ^"goto(1) (html) - GOTO(1) - Manuals - Etsh Project (V6Shell)".etsh.nl.
  5. ^"fd2(1) (html) - FD2(1) - Manuals - Etsh Project (V6Shell)".etsh.nl.
  6. ^"glob(1) (html) - GLOB(1) - Manuals - Etsh Project (V6Shell)".etsh.nl.

External links

[edit]
Operating systems
Programming languages
Software
Associated institutions
Other
Retrieved from "https://en.wikipedia.org/w/index.php?title=Thompson_shell&oldid=1321730114"
Category:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp