start page | rating of books | rating of authors | reviews | copyrights

Book HomeBook TitleSearch this book

Appendix A. Related Shells

Contents:

The Bourne Shell
The 1988 Korn Shell
The IEEE 1003.2 POSIX Shell Standard
dtksh
tksh
pdksh
bash
zsh
Workalikes on PC Platforms

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's inability to capture as big a share of the market as other operating platforms. In particular, Unix has been relegated to its current position as a very popular operating system for servers, but it's a rarity on desktop machines.

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, it is one of the strengths of Unix that the shell is replaceable, and thus a number of shells are currently available; the differences between them are often not all that great. We believe that the Korn shell is one of 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. In fact, it seems that shells, Bourne-compatible or not, continue to proliferate.

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

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.[145] 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.

[145] 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.

Chapter 1
The cd old new and cd - forms of the cd command.

Tilde (~) expansion.

The Bourne shell always follows the physical file layout, which affects what happens when you cd .. out of somewhere that was a symbolic link.

The built-in commands don't have online help.

Some older versions of the Bourne shell don't support the jobs command and job control, or they may require being invoked as jsh in order to enable job control features.

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

Chapter 3
Aliases are not supported.

set -o options don't work. The Bourne shell supports the abbreviations listed in the "Options" table in Appendix B, except -A, -b, -C, -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:

.sh.edchar .sh.version HISTEDIT LINENO PS4
.sh.edcol COLUMNS HISTFILE LINES PWD
.sh.edmode EDITOR HISTSIZE OLDPWD RANDOM
.sh.edtext ENV LANG OPTARG REPLY
.sh.match FCEDIT LC_ALL OPTIND SECONDS
.sh.name FIGNORE LC_COLLATE PPID TMOUT
.sh.subscript FPATH LC_CTYPE PS3 VISUAL
.sh.value HISTCMD LC_NUMERIC    

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

Chapter 4
Extended variable names (those with a dot in them), as well as compound variable assignment are not available, nor is string concatenation with the += operator.

Indirect variables (namerefs) are not available.

The whence command is not available; use type instead.

The pattern-matching variable operators (%, %%, #, ##, etc.) and advanced (regular expression) wildcards are not available; use the external command expr instead.

Autoloaded functions are not available, and only POSIX-style functions (those defined using the name() syntax) may be used.

Command substitution syntax is different: use the older `command` instead of $(command). (Some vendors have enhanced their Bourne shells to support the $(command) notation, since it's defined by the POSIX standard.)

Chapter 5
return may only be used from within a function.

Conditional tests use older syntax: [ condition ] or test condition instead of [[ condition ]]. These are actually two forms of the same command (see the test(1) manual page).

The logical operators && and || are -a and -o instead. Supported test operators differ from system to system.[146]

[146] In the original Version 7 Bourne Shell (and in Berkeley Unix systems through 4.3BSD), test and [ condition ] were actually external commands. (They were hard links to each other in /bin.) However, they've been built into the Bourne shell in all systems since System III (circa 1981).

The ! keyword to reverse the exit status of a command was not in the SVR4 Bourne shell, although it may be available on your system, since it is required by POSIX.

The select construct isn't supported. Neither is the arithmetic for loop, and there is no way to fall through from one case to another inside a case statement.

There is no equivalent for TMOUT.

Chapter 6
The SVR4 Bourne shell getopts command is similar, but not identical to, that in ksh. It does not allow options that begin with a plus sign, nor any of the advanced features described in Appendix B.

Arithmetic isn't supported: use the external command expr instead of the $((...)) syntax. For numeric conditionals, use the old condition test syntax and relational operators -lt, -eq, etc., instead of ((...)). let isn't supported.

Array variables and the typeset command are not supported.

Chapter 7
The following I/O redirectors are not supported:[147]

[147] The <> operator was in the original Version 7 Bourne shell, but not documented, since it didn't always work correctly across all Unix systems. Its availability should not be relied upon for Bourne shell programming.

>| <> <<< <&p >&p <&n- >&n- |&

print isn't supported (use echo instead). printf is generally available as an external command.

None of the options to read are supported, nor is the ability to supply a prompt with the first variable's name.

The Bourne shell does not do special interpretations of pathnames, such as /dev/fd/2 or /dev/tcp/ftp.oreilly.com/ftp.

The $"..." and $'...' quoting mechanisms are not available.

Chapter 8
Job control is supported, but only if the shell is invoked with the -j option or as jsh.

The - option to trap (reset trap to the default for that signal) is not available. Instead, a missing trap indicates that the supplied traps should be reset. trap accepts only signal numbers, not logical names.

Coroutines aren't supported.

The wait command only accepts process IDs.

Chapter 9
The ERR and DEBUG fake signals are not available. The EXIT fake signal is supported, as signal 0.

set -n takes effect even in interactive shells.

The output from tracing with set -x is not customizable (no PS4 variable).

Discipline functions are not available.

Chapter 10
Privileged mode isn't supported. (Some Bourne shells do have it.)

The ulimit and umask commands are not as capable.

The KEYBD trap is not available.



Library Navigation Links

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