Why use the Bourne-Again Shell?

When choosing between UNIX shells, shells can generally be split into two broad categories:
Bourne based
These shells derive from the sh(1), or Bourne shell. Bourne is the standard baseline shell for programming purposes.
C-Shell based
These shells derive from the csh(1), a different shell.
One generally accepted fact about the C-Shell is that it is woefully inadequate as a programming tool. There are a lot of perfectly reasonable things that can't be done in it, such as redirecting the standard error while leaving the standard output alone. Tom Christansen's Csh Programming Considered Harmful discusses these reasons at more length.

It is necessary, then, to know the Bourne shell for programming purposes. The question then becomes whether it makes sense to use an interactive shell which is compatible with Bourne-ese or one which uses an entirely different language. If you believe the former is preferable, you want the Bourne-Again Shell.

Bash is not as popular as the TCshell around here, at least so far. Both of these shells offer a lot of bells and whistles which are handy for interactive use. Tcsh also has some additional features (most of them chrome IMHO.)

One important feature bash has and other shells don't is functions. These are more powerful than alises in that they may perform arbitrary actions with parameters and work just like shell scripts. Consider the following a-to-d converter function defined in bash:

function atod () { if [ $# = 0 ]; then tr a d; else cat "$@" | tr a d; fi } Note that it will work for any number of filenames, and use standard input if no arguments are given. It is not possible to write a csh alias to do the same thing; it won't work with pipes and the like.

The best way to start figuring out how to use bash is to:

Marc V 8-93