Chapter 4. The Bash and Korn Shells

 < Day Day Up > 

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. The Bourne shell itself has not 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.

On most commercial Unix systems, including Solaris, /bin/ksh is ksh88 . On Mac OS X (10.4 and newer), however, it's a recent version of ksh93 from AT&T Research.

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 and Mac OS X. Because ksh88 is still commonly found, and because the source code for ksh93 is available, this chapter also covers the two main versions of the Korn shell , ksh88 and ksh93. It presents the following topics:

  • 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. Another page is http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html. http://www.kornshell.com provides considerable information about the Korn shell. The section "Shell Source Code URLs" in Chapter 3 provides Internet URLs for source code download. See also Classic Shell Scripting, Learning the Korn Shell, and Learning the bash Shell, which are listed in the Bibliography.

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. Practically speaking, ksh93 binaries on commercial Unix systems tend to be very early versions of ksh93; you should download the source and build your own executable version if you wish to use ksh93 for production work.

     < Day Day Up > 


    Unix in a Nutshell
    Unix in a Nutshell, Fourth Edition
    ISBN: 0596100299
    EAN: 2147483647
    Year: 2005
    Pages: 201

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