Learning the Korn Shell

Learning the Korn ShellSearch this book
Previous: A.3 wksh Appendix A
Related Shells
Next: A.5 bash
 

A.4 pdksh

If your system does not have the November 1988 Korn shell, there is a public domain version known as pdksh . pdksh is available as source code in various places on the Internet, including the USENET newsgroup comp.sources.unix. It comes with instructions for building and installing it on various BSD-derived UNIX platforms (especially SunOS).

pdksh was written by Eric Gisin, who based it on Charles Forsyth's public domain Version 7 Bourne shell. It has all Bourne shell features plus some of the Korn shell extensions and a few features of its own.

Its emacs editing mode is actually more powerful than that of the 1988 Korn shell. Like the full emacs editor, you can customize the keystrokes that invoke editing commands (known as key bindings in emacs terminology). Editing commands have full names that you can associate with keystrokes by using the bind command.

For example, if you want to set up [CTRL-U] to do the same thing as [CTRL-P] (i.e., go back to the previous command in the history file), you could put this command in your .profile :

bind '^U'=up-history

You can even set up two-character escape sequences, which (for example) allow you to use ANSI arrow keys as well as control characters, and you can define macros , i.e., abbreviations for sequences of editing commands.

The public domain Korn shell's additional features include alternation wildcards (borrowed from the C shell) and user-definable tilde notation, in which you can set up ~ as an abbreviation for anything, not just user names. There are also a few subtle differences in integer expression evaluation and aliasing.

Otherwise, pdksh lacks a few features of the official version. In particular, it lacks the following:

  • The built-in variables COLUMNS , ERRNO , LINENO , LINES , and PS4 .

  • Array variables.

  • The fake signals ERR and EXIT within functions.

  • Advanced (regular expression) wildcards.

  • The newer syntax ( [[ ... ]] ) for conditional tests (the older Bourne shell syntax is supported).

  • The advanced I/O redirectors >| , <> , <&p , >&p , and |& . Coroutines are not supported.

  • The options errexit , markdirs , noclobber , nolog , and privileged .

  • Of the typeset options, only -f (function) -i (integer), -r (read-only), and -x (export) are supported.

The documentation (manual page) of pdksh is incomplete-which is especially a shame because what exists is considerably better organized than the Korn shell's man page! For example, it gives the syntax of command lines and control structures in Extended Backus-Naur Form (BNF), which is not only precise and unambiguous but is the lingua franca of computer language experts.

However, pdksh is a worthwhile alternative to the C and Bourne shells for those who can't get the official version of the Korn shell.


Previous: A.3 wksh Learning the Korn Shell Next: A.5 bash
A.3 wksh Book Index A.5 bash

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