1.6. There Are Many Shells
With most operating systems, the command intepreter is built in; it is an integral part of the operating system. With Unix, your command interpreter is just another program. Traditionally, a command interpreter is called a "shell," perhaps because it protects you from the underlying kernel -- or because it protects the kernel from you!
In the early 1980s, the most common shells were the Bourne shell (sh) and the C shell (csh). The Bourne shell (Section 3.3) (named after its creator, Steve Bourne) came first. It was excellent for shell programming (Section 1.8). But many Unix users (who were also writing programs in the C language) wanted a more familiar programming syntax -- as well as more features for interactive use. So the C shell came from Berkeley as part of their Unix implementation. Soon (on systems that gave you the choice, at least) csh was much more popular for interactive use than sh. The C shell had a lot of nice features that weren't available in the original Bourne shell, including job control (Section 23.1) and history (Section 30.2). However, it wasn't hard for a shell programmer or an advanced user to push the C shell to its limits.
The Korn shell (also named after its creator, David Korn) arrived in the mid-1980s. The ksh is compatible with the Bourne shell, but has most of the C shell's features plus features like history editing (Section 30.14), often called command-line editing. The Korn shell was available only with a proprietary version of Unix, System V -- but now a public-domain version named pdksh is widely available.
The "Bourne-again" shell, bash, is from the Free Software Foundation. It's fairly similar to the Korn shell. It has most of the C shell's features, plus command-line editing and a built-in help command. The programming syntax, though, is much more like the original Bourne shell -- and many systems (including Linux) use bash in place of the original Bourne shell (but still call it sh).
The Z shell, zsh, is an interesting hybrid. It tries to be compatible with most features of all the other shells, with compatibility modes and a slew of options that turn off conflicting features. In its soul, though, zsh has a different way of doing some things. It's been accused of feature creep. But zsh users love its flexibility.
There are other shells. If you're a fan of the Bell Labs research operating system named Plan 9 (actually, Plan 9 from Outer Space), you'll be happy to know that its shell, rc, has been ported to Unix. If you program in Tcl, you'll probably be familiar with tclsh, which lets you intermix Unix commands with Tcl commands. (And we can't forget wish , the shell that's a superset of tclsh: it uses Tcl/Tk commands to let you build graphical interfaces as you go.) Least -- but certainly not last -- if you're a minimalist who needs the original sh, a newer shell named ash emulates the late-1980s Bourne shell.
In this book, we try to be as generic as we can. Where we need to get specific, many examples are shown in the style of both the Bourne shell and the C shell -- for instance, we'll often show Bourne-shell functions side-by-side with C-shell aliases. Because bash and ksh can read scripts written for the original Bourne shell, we use original sh syntax to make our shell programming as portable as possible.
--JP and ML
Copyright © 2003 O'Reilly & Associates. All rights reserved.