-->
Previous Table of Contents Next


Chapter 12
pdksh

by Rick McMullin and Tim Parker

In This Chapter
•   The public domain korn shell (pdksh)
•   Shell prompts
•   Job control
•   Key bindings
•   Customizing your pdksh
•   pdksh commands
•   pdksh variables

In the last chapter, you saw the Bourne Again Shell (bash) in some detail. Not everyone wants to use the bash shell, so several other shells are included with most Linux systems. One of them is pdksh, a variation on the Korn shell. We’ll also look at how you can customize your copy of pdksh, as well as several of the important commands and variables used by the shell.

The Public Domain Korn Shell (pdksh)

The Korn shell, written by David Korn, was the third mainstream shell written for UNIX (after the Bourne shell and the C shell). Because of this, it incorporates many of the features of the Bourne and C shells together. The Korn shell is not usually distributed with all UNIX versions, so many users don’t get to work with it. The Korn shell is important to UNIX users, though, because it builds a lot of the important new features of the C shell into the much older Bourne shell, while remaining completely compatible with sh. Because of the Korn shell’s popularity among UNIX users, a version was developed for Linux called the Public Domain Korn Shell, or pdksh.

The current version of the Public Domain Korn Shell does not support all of the features that exist in the commercial version of the Korn shell. It does support most of the main features, however, and adds a few new features of its own.

Command-Line Completion

Often, when you are entering commands at the command line, the complete text of the command is not necessary in order for pdksh to be able to determine what you want to do. Command-line completion enables you to type in a partial command, and then by entering a key sequence, tell pdksh to try to finish the command for you.

pdksh does not default to allow the user to perform command-line completion. You must enter a command to tell pdksh that you want to be able to use command-line completion. In order to enable command-line completion, enter one of the following commands:

set -o emacs

set -o vi

This causes pdksh to accept command editing that is similar to emacs or vi. Choose the editor that you are most familiar with, and use the basic editor commands for command-line editing.


Note:  
Most people find the emacs editing mode more user-friendly than the vi editing mode.

When using vi command-line editing, you must be in command mode when you enter any of the editing commands. You can enter command mode by pressing the Esc key. When command mode has been entered, you cannot type any characters onto the command line until you enter edit mode. There are many ways of doing this, but the usual way is by pressing the i (insert) key.


After the command-line completion function is enabled, you can perform command-line completion by pressing the Esc key twice (when using emacs command-line editing) or by pressing \ (when using vi command-line editing). For example, if your current directory contains the files


News/    bin/    games/   mail/    sample.text    test/

and you want to edit the file sample.text using the vi text editor, enter the following command:


vi sample.text

After the “s” is typed, the only file that you can be referring to is sample.text because it is the only file in the current directory that begins with the letter “s”. To get pdksh to finish the command when you are using emacs-style command editing, press the Esc key twice after typing s:


vi s<escape><escape>

To get pdksh to finish the command when you are using vi command editing, press the \ key after typing s:


vi s\

Either of these commands causes pdksh to finish the line for you and displays the result on the screen. The command does not execute until you press the Enter key. This is to give you a chance to confirm that the command pdksh displays is the command that you really intend.

If the sample.text file is not the only file in the directory that begins with the letter “s”, pdksh completes the command as far as it can and then beeps, indicating that it needs more information to complete the command.


Note:  
The keyboard equivalent of pressing the Esc key is Ctrl+[, usually written as ^[. The caret (^) is the abbreviation for the Ctrl key. Pressing Esc twice using the Ctrl+[ sequence would be written as ^[^[. You may see this convention in books or man pages.


Previous Table of Contents Next