Previous | Table of Contents | Next |
The Original Bourne Shell
The original UNIX shell was written in the mid-1970s by Stephen R. Bourne while he was at AT&T Bell Labs in New Jersey. The Bourne shell was the first shell to appear on UNIX systems, thus it is referred to as the shell. In this book, when I refer to the shell, I am referring to the Bourne shell.
The Bourne shell is usually installed as /bin/sh on most versions of UNIX. For this reason, it is the shell of choice for writing scripts to use on several different versions of UNIX.
In addition to being a command interpreter, the Bourne shell is a powerful language with a programming syntax similar to that of the ALGOL language. It contains the following features:
All Bourne-type shells support these features.
One of the main drawbacks of the original Bourne shell is that it is hard to use interactively. The three major drawbacks are
The C Shell
Bill Joy developed the C shell while he was at the University of California at Berkeley in the early 1980s. It was designed to make interactive use of the shell easier for users. Another design goal was to change the syntax of the shell from the Bourne shells older ALGOL style to the newer C style.
The C language style of the C shell was intended as an improvement because the C language was familiar to the programmers working on UNIX at Berkeley. The idea was that a shell that used C language style syntax would be easier to write scripts in than a shell that used the ALGOL style syntax.
As it turned out, the C shell could not be used for much more than the most trivial scripts. Some of the major drawbacks are
Although the C shell did not catch on for scripts, it has become extremely popular for interactive use. Some of the key improvements responsible for this popularity follow:
The C shell is usually installed on most systems as /bin/csh.
The TENEX/TOPS C shell, tcsh, is a newer version of the C shell that enables you to scroll through the command history using the up and down arrow keys. It also enables you to edit commands using right and left arrow keys.
Although it is widely available in educational UNIX machines, tcsh is not always present on corporate UNIX machines. For more information on obtaining tcsh, take a look at the following URL:
http://www.primate.wisc.edu/software/csh-tcsh-book/
This page includes information on obtaining and installing tcsh in both source and binary form.
The Korn Shell
For a long time, the only two shells to choose from were the Bourne shell and the C shell. This meant that most users had to know two shells, the Bourne shell for programming and the C shell for interactive use.
To rectify this situation, David Korn of AT&T Bell Labs wrote the Korn shell, ksh, which incorporates all the C shells interactive features into the Bourne shells syntax. For this reason, the Korn shell has become a favorite with users.
In recent years, most vendors have started to ship the Korn shell with their versions of UNIX. Usually you will find it installed as /bin/ksh or /usr/bin/ksh.
In general, ksh can be treated as fully compatible with sh, but some differences will prevent scripts from functioning correctly. These exceptions are noted throughout the book.
Some of the additional features that the Korn shell brings to the Bourne shell include the following:
There are three major versions of ksh available:
The Official version is available in binary format (no sources) from
The Public Domain version is available in both binary and source format from
ftp://ftp.cs.mun.ca:/pub/pdksh
For the shell programmer, there is no difference between the Official and the Public Domain versions of kshall scripts that run in one version will run in the other.
For shell users, the Official version provides a few nice features like command line completion with the Tab key rather than the Esc key.
The Desktop version comes with all major implementations of CDE. This version provides the capability to create and display Graphical User Interfaces (GUIs) using ksh syntax. Scripts written for the other two versions of ksh will run correctly under this version.
The POSIX shell is another variant of the Korn shell. Currently, the only major vendor shipping the POSIX shell is Hewlett-Packard. In HP-UX 11.0, the POSIX shell is installed as /bin/sh. The Bourne shell is installed as /usr/old/bin/sh.
Previous | Table of Contents | Next |