Previous Section  < Day Day Up >  Next Section

1.3. History of the Shell

The first significant, standard UNIX shell was introduced in V7 (seventh edition of AT&T) UNIX in late 1979, and was named after its creator, Stephen Bourne. The Bourne shell as a programming language is based on a language called Algol, and was primarily used to automate system administration tasks. Although popular for its simplicity and speed, it lacks many of the features for interactive use, such as history, aliasing, and job control.

The C shell, developed at the University of California, Berkeley, in the late 1970s, was released as part of BSD UNIX. The shell, written primarily by Bill Joy, offered a number of additional features not provided in the standard Bourne shell. The C shell is based on the C programming language, and when used as a programming language, it shares a similar syntax. It also offers enhancements for interactive use, such as command-line history, aliases, and job control. Because the shell was designed on a large machine and a number of additional features were added, the C shell has a tendency to be slow on small machines and sluggish even on large machines when compared with the Bourne shell.

With both the Bourne shell and the C shell available, the UNIX user now had a choice, and conflicts arose over which was the better shell. To provide the best of both worlds, David Korn, from AT&T, invented the Korn shell in the mid-1980s. It was released in 1986 and officially became part of the SVR4 distribution of UNIX in 1988. The Korn shell, really a superset of the Bourne shell, runs not only on UNIX/Linux systems, but also on OS/2, VMS, and DOS. It provides upward compatibility with the Bourne shell, adds many of the popular features of the C shell, and is fast and efficient. The Korn shell has gone through a number of revisions. The most widely used version of the Korn shell is the 1988 version, although the 1993 version has gained popularity. Linux users may find they are running the free version of the Korn shell, called the Public Domain Korn shell, or simply pdksh, a clone of David Korn's 1988 shell. It is free and portable and currently work is underway to make it fully compatible with its namesake, Korn shell, and to make it POSIX compliant. Also available is the Z shell (zsh), another Korn shell clone with TC shell features, written by Paul Falsted, and freely available at a number of Web sites.

With the advent of Linux, the Bourne Again shell (bash) gained popularity as a super Bourne shell. The Bourne Again shell was developed in 1988 by Brian Fox of the Free Software Foundation under the GNU copyright license and is the default shell for the Linux operating system. It was intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. The Bourne Again shell also offers a number of new features (both at the interactive and programming level) missing in the original Bourne shell (yet Bourne shell scripts will still run unmodified). It also incorporates the most useful features of both the C shell and Korn shell. It's big. The improvements over Bourne shell are command-line history and editing, directory stacks, job control, functions, aliases, arrays, integer arithmetic (in any base from 2 to 64), and Korn shell features such as extended metacharacters, select loops for creating menus, the let command, and more.

What is the TC shell? The TC shell is an expanded, completely compatible version of the C shell. Some of the new features are command-line editing (emacs and vi), scrolling the history list, advanced filename, variable, and command completion, spelling correction, job scheduling, automatic locking and logout, time stamps in the history list, and more. It's also big. People often ask, "What does the 'T' in TC shell stand for?" A little history is involved. Back in 1976, DEC announced and shipped a new virtual memory operating system called TOPS-20, based on TENEX, an operating system used by researchers at that time all around the country. One of the most favored features among TOPS-20 users, and one most identified with TOPS-20 itself, was "escape recognition," also called command completion. With this, the user can often get the system to, in effect, type most of a command or symbolic name by pressing the Esc key. The creator of the TC shell was impressed by this and several other features of TENEX/TOPS-20, and created a version of csh that mimicked them called the TENEX C shell, or simply TC shell, tc-shell, or tcsh. Hence, the "T" in TC shell. See info.astrian.net/doc/tcsh/copyright for more information on tcsh.

1.3.1 Uses of the Shell

When running interactively, one of the major functions of a shell is to interpret commands entered at the command-line prompt. The shell parses the command line, breaking it into words (called tokens) separated by whitespace, which consists of tabs, spaces, or a newline. If the words contain special metacharacters, the shell evaluates them. The shell handles file I/O and background processing. After the command line has been processed, the shell searches for the command and starts its execution.

Another important function of the shell is to customize the user's environment, normally done in shell initialization files. These files contain definitions for setting terminal keys and window characteristics; setting variables that define the search path, permissions, prompts, and the terminal type; and setting variables that are required for specific applications such as window managers, text-processing programs, and libraries for programming languages. The Korn/Bash shells and C/TC shells also provide further customization with the addition of history, aliases, and built-in variables set to protect the user from clobbering files, or inadvertently logging out, or to notify the user when a job has completed.

The shell can also be used as an interpreted programming language. Shell programs, also called scripts, consist of commands listed in a file. The programs are created in an editor (although online scripting is permitted). They consist of UNIX/Linux commands interspersed with fundamental programming constructs such as variable assignment, conditional tests, and loops. You do not have to compile shell scripts. The shell interprets each line of the script as if it had been entered from the keyboard. Because the shell is responsible for interpreting commands, it is necessary for the user to have an understanding of what those commands are. See Appendix A for a list of useful UNIX and Linux commands.

1.3.2 Responsibilities of the Shell

The shell is ultimately responsible for making sure that any commands typed at the prompt get executed properly. Included in those responsibilities are:

  1. Reading input and parsing the command line

  2. Evaluating special characters, such as wildcards and the history character

  3. Setting up pipes, redirection, and background processing

  4. Handling signals

  5. Setting up programs for execution

Each of these topics is discussed in detail as it pertains to a particular shell.

    Previous Section  < Day Day Up >  Next Section