Chapter 6. The Bash Shell and Korn Shell


The original Bourne shell distributed with V7 Unix in 1979 became the standard shell for writing shell scripts. The Bourne shell is still to be found in /bin/sh on many commercial Unix systems. It hasn't changed that much since its initial release, although it has seen modest enhancements over the years. The most notable new features were the CDPATH variable and a built-in test command with System III (circa 1980), command hashing and shell functions for System V Release 2 (circa 1984), and the addition of job control features for System V Release 4 (1989).

Because the Berkeley C shell (csh) offered features that were more pleasant for interactive use, such as command history and job control, for a long time the standard practice in the Unix world was to use the Bourne shell for programming and the C shell for daily use. David Korn at Bell Labs was the first developer to enhance the Bourne shell by adding csh-like features to it: history, job control, and additional programmability. Eventually, the Korn shell's feature set surpassed both the Bourne shell and the C shell, while remaining compatible with the Bourne shell for shell programming. Today, the POSIX standard defines the "standard shell" language and behavior based on the System V Bourne shell, with a selected subset of features from the Korn shell.

The Free Software Foundation, in keeping with its goal to produce a complete Unix work-alike system, developed a clone of the Bourne shell, written from scratch, named "Bash," the Bourne-Again SHell. Over time, Bash has become a POSIX-compliant version of the shell, with many additional features. A large part of these additional features overlap the features of the Korn shell, but Bash is not an exact Korn shell clone.

This chapter covers Bash, which is the primary shell for GNU/Linux. It also covers the two main versions of the Korn shell, ksh88 and ksh93. The following topics are presented:

  • Overview of features

  • Invoking the shell

  • Syntax

  • Functions

  • Variables

  • Arithmetic expressions

  • Command history

  • Job control

  • Command execution

  • Restricted shells

  • Built-in commands

http://www.gnu.org/software/bash/bash.html provides information about the Bash shell, as does http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html. http://www.kornshell.com provides considerable information about the Korn shell. See also Classic Shell Scripting, Learning the Korn Shell, and Learning the bash Shell (all from O'Reilly).

All references in this chapter to the Bash shell are for Bash Version 3. Many of the features listed for ksh93 are found only in the version available from AT&T Research.



Linux in a Nutshell
Linux in a Nutshell
ISBN: 0596154488
EAN: 2147483647
Year: 2004
Pages: 147

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net