home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Learning the Korn Shell

Learning the Korn ShellSearch this book
Previous: 10.3 System Security Features Appendix A Next: A.2 The IEEE 1003.2 POSIX Shell Standard

A. Related Shells

The fragmentation of the UNIX marketplace has had its advantages and disadvantages. The advantages came mostly in the early days: lack of standardization and proliferation among technically savvy academics and professionals contributed to a healthy "free market" for UNIX software, in which several programs of the same type (e.g., shells, text editors, system administration tools) would often compete for popularity. The best programs would usually become the most widespread, while inferior software tended to fade away.

But often there was no single "best" program in a given category, so several would prevail. This led to the current situation, where multiplicity of similar software has led to confusion, lack of compatibility, and-most unfortunate of all-UNIX' inability to capture as big a share of the market as other operating platforms (MS-DOS, Microsoft Windows, Novell NetWare, etc.).

The "shell" category has probably suffered in this way more than any other type of software. As we said in the Preface and Chapter 1, Korn Shell Basics , of this book, several shells are currently available; the differences between them are often not all that great. We believe that the Korn shell is the best of the most widely used shells, but other shells certainly have their staunch adherents, so they aren't likely to fade into obscurity for a while.

Therefore we felt it necessary to include information on shells similar to the 1988 UNIX Korn shell. This Appendix summarizes the differences between the latter and the following:

  • The standard Version 7 Bourne shell, as a kind of "baseline"

  • The IEEE POSIX 1003.2 shell Standard, to which the Korn shell and other shells will adhere in the future

  • The Windowing Korn shell ( wksh ), a Korn shell with enhancements for X Window System programming

  • pdksh , a widely-used public domain Korn shell

  • The bash shell, which is another enhanced Bourne shell with some C shell and Korn shell features

  • Korn shell workalikes on desktop PC platforms, including the MKS Toolkit shell

We'll conclude this appendix with a look at the Korn shell's future: the next release's expected features, obsolescent features of the current shell, and other issues.

A.1 The Bourne Shell

The Korn shell is almost completely backward-compatible with the Bourne shell. The only significant feature of the latter that the Korn shell doesn't support is ^ (caret) as a synonym for the pipe (|) character. [1] This is an archaic feature that the Bourne shell includes for its own backward compatibility with earlier shells. No modern UNIX version has any shell code that uses ^ as a pipe.

[1] There are also a few differences in how the two shells react to certain extremely pathological input. Usually, the Korn shell processes correctly what causes the Bourne shell to "choke."

To describe the differences between the Bourne shell and the Korn shell, we'll go through each chapter of this book and enumerate the features discussed in the chapter that the Bourne shell does not support. Although some versions of the Bourne shell exist that include a few Korn shell features, [2] we refer to the standard, Version 7 Bourne shell that has been around for many years.

[2] For example, the Bourne shell distributed with System V supports functions and a few other Korn shell features.

Chapter 1

The cd old new and cd - forms of the cd command; tilde ( ~ ) expansion; the jobs command.

Chapter 2, Command-line Editing

All. (I.e., the Bourne shell doesn't support any of the history and editing features discussed in Chapter 2 .)

Chapter 3, Customizing Your Environment

Aliases; set -o options. The Bourne shell supports the "abbreviations" listed in the "Options" table in Appendix B, Reference Lists -except -A , -h , -m , -p , and -s . Environment files aren't supported; neither is the print command (use echo instead). The following built-in variables aren't supported:

Some of these variables (e.g., EDITOR and VISUAL ) are still used by other programs, like mail and news readers.

Chapter 4, Basic Shell Programming

Functions; the whence command; pattern-matching variable operators ( % , %% , # , ## ); advanced (regular expression) wildcards-use the external command expr instead. Command substitution syntax is different: use the older ` command ` instead of $( command ).

Chapter 5, Flow Control

Conditional tests use older syntax: [ condition ] or test condition instead of [[ condition ]] . These are actually two forms of the same external command (see the test(1) manual page). The logical operators && and || are -a and -o instead. Supported test operators differ from system to system. The select construct isn't supported.

Chapter 6, Command-line Options and Typed Variables

Use the external command getopt instead of getopts , but note that it doesn't really do the same thing. Integer arithmetic isn't supported: use the external command expr instead of the $(( arithmetic-exp )) syntax. For integer conditionals, use the old condition test syntax and relational operators -lt , -eq , etc., instead of (( arithmetic-expr )) . let isn't supported. Array variables and the typeset command are not supported.

Chapter 7, Input/Output and Command-line Processing

The following I/O redirectors are not supported:


print isn't supported (use echo instead). None of the options to read are supported.

Chapter 8, Process Handling

Job control-specifically, the jobs , fg , and bg commands. Job number notation with % , i.e., the kill and wait commands only accept process IDs. The - option to trap (reset trap to the default for that signal). trap only accepts signal numbers, not logical names. Coroutines aren't supported.

Chapter 9, Debugging Shell Programs

The ERR and DEBUG fake signals. The EXIT fake signal is supported, as signal 0.

Chapter 10, Korn Shell Administration

The ulimit command and privileged mode aren't supported. The Bourne shell's restrictive counterpart, rsh , only inhibits assignment to PATH .

Previous: 10.3 System Security Features Learning the Korn Shell Next: A.2 The IEEE 1003.2 POSIX Shell Standard
10.3 System Security Features Book Index A.2 The IEEE 1003.2 POSIX Shell Standard

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System