Appendix A. Related Shells
The fragmentation of the Unix marketplace has had its advantages anddisadvantages. The advantages came mostly in the early days: lack of standardization and proliferation among technicallysavvy academics and professionalscontributed to a healthy "free market" for Unix software, in whichseveral 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 similarsoftware has led to confusion, lack of compatibility, and -- mostunfortunate of all -- Unix's inability to capture as big a share ofthe market as other operating platforms.In particular, Unix has been relegated to its current position as a verypopular operating system for servers, but it's a rarity on desktop machines.
The "shell" category has probably suffered in this way more thanany other type of software. As we said in,it is one of the strengths of Unix that the shell is replaceable, and thusa number of shells are currently available; the differencesbetween them are often not all that great. We believe that the Kornshell is one of the best of the most widely used shells, but other shellscertainly have their staunch adherents, so they aren't likely tofade 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 Appendixsummarizes the differences between the Korn shell and the following shells:
A.1. The Bourne Shell
This is an archaic feature thatthe Bourne shell includes for its own backward compatibilitywith earlier shells. No modern Unix version has any shell codethat 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 correctlywhat causes the Bourne shell to "choke."
To describe the differences between the Bourne shelland the Korn shell, we'll go through each chapter of this bookand enumerate the features discussed in the chapter that the Bourneshell does not support.
The cd
old new and cd - forms of the
cd command.
Tilde ( ~ ) expansion.
The Bourne shell always follows the physical file layout, which affectswhat happens when you cd .. out of somewhere thatwas a symbolic link.
The built-in commands don't have online help.
Some older versions of the Bourne shell don't supportthe jobs command and job control,or they may require being invoked as jsh in orderto enable job control features.
All (i.e., the Bourne shell doesn't support any ofthe history and editing features discussed in ).Aliases are not supported.
set -o options don't work. The Bourne shellsupports the abbreviations listed in the "Options" table in, except-A,-b,-C,-m,-p,and -s.
Environment files aren't supported; neither is the printcommand (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.
Extended variable names (those with a dot in them), as well as compoundvariable assignment are not available, nor is string concatenationwith the += operator.
Indirect variables (namerefs) are not available.
The whence command is not available; usetype instead.
The pattern-matching variable operators( % , %% , # , ## , etc.)and advanced (regular expression) wildcards are not available; usethe external command expr instead.
Autoloaded functions are not available, andonly 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.)
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]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 eachother in /bin.) However, they've been built intothe Bourne shell in all systems since System III (circa 1981).
The ! keywordto reverse the exit status of a commandwas not in the SVR4 Bourne shell,although it may be available on your system, since it isrequired 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 anotherinside a case statement.
There is no equivalent for TMOUT .
The SVR4 Bourne shell
getopts command is similar, butnot identical to, that in
ksh.It does not allow options that begin with a plus sign,nor any of the advanced features described in.
Arithmetic isn't supported: use the external commandexpr instead ofthe $(( ... )) syntax. For numeric conditionals, use the old condition test syntaxand relational operators -lt, -eq, etc., instead of (( ... )) .let isn't supported.
Array variables and the typeset command are not supported.
The following I/O redirectors are not supported:
[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.