## A.6. pdksh

Many of the Open Source Unix-like systems, such as GNU/Linux, come with the Public Domain Korn Shell, pdksh. pdksh is available as source code; start at its home page: http://www.cs.mun.ca/~michael/pdksh/. It comes with instructions for building and installing on various Unix platforms.

pdksh was originally written by Eric Gisin, who based it on Charles Forsyth's public-domain clone of the Version 7 Bourne shell. It is mostly compatible with the 1988 Korn shell and POSIX, with some extensions 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.

pdksh lacks the following features of the official version:

- The built-in variable `LINES`.

- The DEBUG fake signal. The fake signals ERR and EXIT within functions.

- Functions inherit the trap settings of the main script.

- The POSIX file expansion character classes (`[[:alpha:]]`, etc.) are not available.

- The read command and `select` loop do not use the command-line editing modes.

- The last command of a pipeline is not run in the parent shell. Thus, `echo hi | read x; print $x` doesn't work the same as in ksh. (Most Bourne-style shells work this same way.)

- The set -o option form of ksh is set -X option in pdksh.

Although it lacks most ksh93 extensions, pdksh is a worthwhile alternative to the C and Bourne shells.

Copyright © 2003 O'Reilly & Associates. All rights reserved.