ArticleslgStudy

science

Thompson shell

Thompson shell is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Thompson shell rather than just read about it. In short: The Thompson shell was the first Unix shell, introduced in the first version of Unix in 1971, and was written by Ken Thompson. 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.

Key takeaways

  • Thompson shell belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Thompson shell to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Thompson shell from memory before moving on to harder problems.

Reference excerpt

The Thompson shell was the first Unix shell, introduced in the first version of Unix in 1971, and was written by Ken Thompson. 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 interpreter and the concept of making the shell a user program outside of the 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. 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. 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. 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 as MS-DOS.

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 chdir, exit, login, newgrp, shift, and wait. 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 : 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. 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. The shell supports globbing, but actually implements it by deferring it to a glob 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 in Version 7 Unix and the C shell in 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 as part of several Ancient UNIX source distributions and has been ported to modern Unices as a historical exhibit.

See also Comparison of command shells

References

External links Manual page for the Thompson shell in Unix 1st Edition. The Evolution of the Unix Time-Sharing System - describes the early development of the shell Origins of the Bourne 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 a backwards-compatible "enhanced version" with some modern features)

Worked examples

Example 1 — a first encounter with Thompson shell

Start with the simplest possible case. Write down what Thompson shell claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Thompson shell before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Thompson shell ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Thompson shell

In research
Thompson shell appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Thompson shell in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Thompson shell is common in secondary-school and first-year university syllabi. It links to neighbouring topics Unix shells, so understanding it makes those chapters shorter.
In everyday life
Look for Thompson shell outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Thompson shell” →

How to study Thompson shell in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Thompson shell means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Thompson shell out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Thompson shell in simple terms?

The Thompson shell was the first Unix shell, introduced in the first version of Unix in 1971, and was written by Ken Thompson. 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 develop…

Why does Thompson shell matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Thompson shell?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Thompson shell.

Tags

  • Unix shells

Keep exploring