bash is probably the most popular "third-party" shell that is available for Unix and other systems. In particular, it is the default shell on GNU/Linux systems. (It also comes on the "freeware" CD with Solaris 8.) You can get it from the Internet, via anonymous FTP to ftp.gnu.org in the directory /pub/gnu/bash. You can also order it from its maker at the address listed here.
The Free Software Foundation 59 Temple Place - Suite 330 Boston, MA 02111-1307 (617) 542-2652 (617) 542-5942 (fax) [email protected] http://www.gnu.org
Bash was written by Brian Fox and Chet Ramey. Chet Ramey currently maintains it. Its name is in line with the FSF's penchant for bad puns: it stands for Bourne-Again Shell. Although bash is easily available and you don't have to pay for it (other than the cost of media, phone calls, etc.), it's not really public domain software. While public domain software doesn't have licensing restrictions, the FSF's software does. But those restrictions are diametrically opposed to those in a commercial license:[151] instead of agreeing not to distribute the software further, you agree not to prevent it from being distributed further! In other words, you enjoy unrestricted use of the software as long as you agree not to inhibit others from doing the same. Richard Stallman, the founder of the FSF, invented this intriguing and admirable concept.
[151] Accordingly, the document that spells out these restrictions is called a copyleft.
These days, the ideals of the Free Software and Open Source movements, the GNU project, and the quality of GNU software are all well known. The most popular GNU system is GNU/Linux, which uses the Linux kernel and GNU utilities to make a complete, fully functional, Unix- and POSIX-compatible computing environment.
bash is fully compatible with the 1992 POSIX standard. It has several of the most important Korn shell features and the C shell features that the Korn shell has appropriated, including aliases, functions, tilde notation, emacs and vi editing modes, arithmetic expressions, job control, etc.
The overlap of features between bash and the Korn shell has increased in recent years. It includes many ksh93 features. But it is not an exact ksh clone. The bash FAQ, published monthly by Chet Ramey, lists the following differences between bash and ksh93. Items enclosed in square brackets ([...]) are listed in this book, but not in the FAQ.
The following new things in ksh93 are not available in bash 2.05:
Associative arrays
Floating-point arithmetic and variables
Math library functions
${!name[sub]} name of subscript for associative array
"." is allowed in variable names to create a hierarchical namespace
More extensive compound assignment syntax
Discipline functions
sleep and getconf built-ins (bash has loadable versions)
typeset -n and nameref variables
The KEYBD trap
The variables: .sh.edchar, .sh.edmode, .sh.edcol, .sh.edtext, .sh.version, .sh.name, .sh.subscript, .sh.value, HISTEDIT [The .sh.match variable also]
Backreferences in pattern matching (\N)
The & operator in pattern lists for matching
print -f (bash uses printf)
fc has been renamed to hist
The dot command (.) can execute shell functions
Exit statuses between 0 and 255
The set -o pipefail option
The += variable assignment operator
TMOUT is default timeout for read and select
<&n- and >&n- redirections (combination dup and close) [Here-strings with <<<]
FPATH and PATH mixing
getopts -a
The -R invocation option
DEBUG trap now executed before each simple command, instead of after
The printf %H, %P, %T modifiers, and an output base for %d [Also %Z.]
The following new things in ksh93 are present in bash 2.05:
The for ((...;...;...)) ; do list; done arithmetic for command
The ?:, ++, --, and comma (,) arithmetic operators
The shell variable expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]}, ${!param*}
Compound array assignment
The ! reserved word
Loadable built-ins -- but ksh uses builtin while bash uses enable
The command, builtin, and disown built-ins
New $'...' and $"..." quoting
FIGNORE (but bash uses GLOBIGNORE), HISTCMD
set -o notify, set -C
Changes to kill built-in
read -A (bash uses read -a)
read -t/read -d
trap -p
exec -a/exec -c
The dot command (.) restores the positional parameters when it completes
The test command conforms to POSIX.
umask -S
unalias -a
Command and arithmetic substitution performed on PS1, PS4, and ENV
Command name completion
ENV processed only for interactive shells
bash has many features of its own that make it a very powerful and flexible environment. Here are some of the highlights:
You can put backslash-escapes in the primary prompt string (PS1) for which bash substitutes things like the date, time, current working directory, machine name, user name, shell, etc.
The commands builtin, command, and enable give you more control over the steps bash goes through to look for commands -- i.e., bash's analogue to the list of command search steps in Chapter 7.
The emacs editing mode is customizable, even more so than its equivalent in pdksh. You can use the bind command to set up your own keystroke preferences, and there are several more commands available -- including the ability to undo your last command.
You can also rebind keystrokes in vi editing mode.
pushd and popd are built-in, as they are in the C shell.
Indexed arrays may be of unlimited size.
Many new options and variables let you customize your environment with unprecedented flexibility. This includes set -o posix for strict POSIX conformance.
We're compelled to say that many users prefer bash to the Korn shell. With the increasing popularity of GNU/Linux and various BSD-derived systems, it's not clear which shell has the larger user base. In any case, bash is definitely an excellent choice. We recommend the book Learning the bash Shell by Cameron Newham and Bill Rosenblatt, published by O'Reilly & Associates. (It is based on the first edition of this book.)
Copyright © 2003 O'Reilly & Associates. All rights reserved.