Chapter 27. Shell Interpretation

What the Shell Does

As we’ve said, the shell is just another program. It’s responsible for interpreting the commands you type. There are several commonly used shells, primarily based on two or three major families and a wide variety of other projects:

  • The Bourne shell (sh) and its derivatives and progeny (including bash, ash, and even the Korn shell ksh)

  • The C shell (csh) and its progeny (including tcsh)

  • The Korn shell (ksh) and variants (including pdksh and zsh [1])

  • Specialized shells based on languages such as Python, TCL, perl, and so on.

  • Shells invented to meet specific needs such as restricted command access (rsh), recovery after a system failure (sash), and downloading, installing, and configuring software libraries.

If you can think of a reason to have a specialized shell, someone probably has already written one to meet that need.

Interpreting your commands might seem simple enough, but a lot of things happen between the time you press RETURN and the time the computer actually does what you want. The process of interpretation is very complex: the shell has to break the command into words and expand aliases (Section 29.2), history operators (Section 30.8), and shell and environment variables (Section 35.3, Section 35.9). It also sets up standard input and output streams (Section 43.1) and performs a lot of other tasks. Indeed, if a command looks right but doesn’t work right, the cause is probably either one of the following:

  • File permissions ...

Get Unix Power Tools, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.