autoconf: Shellology
1
1 11.1 Shellology
1 ===============
1
1 There are several families of shells, most prominently the Bourne family
1 and the C shell family which are deeply incompatible. If you want to
1 write portable shell scripts, avoid members of the C shell family. The
1 the Shell difference FAQ
1 (http://www.faqs.org/faqs/unix-faq/shell/shell-differences/) includes a
1 small history of Posix shells, and a comparison between several of them.
1
1 Below we describe some of the members of the Bourne shell family.
1
1 Ash
1 Ash is often used on GNU/Linux and BSD systems as a light-weight
1 Bourne-compatible shell. Ash 0.2 has some bugs that are fixed in
1 the 0.3.x series, but portable shell scripts should work around
1 them, since version 0.2 is still shipped with many GNU/Linux
1 distributions.
1
1 To be compatible with Ash 0.2:
1
1 - don't use `$?' after expanding empty or unset variables, or
1 at the start of an `eval':
1
1 foo=
1 false
1 $foo
1 echo "Do not use it: $?"
1 false
1 eval 'echo "Do not use it: $?"'
1
1 - don't use command substitution within variable expansion:
1
1 cat ${FOO=`bar`}
1
1 - beware that single builtin substitutions are not performed by
1 a subshell, hence their effect applies to the current shell!
1 ⇒Shell Substitutions, item "Command Substitution".
1
1 Bash
1 To detect whether you are running Bash, test whether
1 `BASH_VERSION' is set. To require Posix compatibility, run `set
1 -o posix'. ⇒Bash Posix Mode (bash)Bash POSIX Mode, for
1 details.
1
1 Bash 2.05 and later
1 Versions 2.05 and later of Bash use a different format for the
1 output of the `set' builtin, designed to make evaluating its
1 output easier. However, this output is not compatible with earlier
1 versions of Bash (or with many other shells, probably). So if you
1 use Bash 2.05 or higher to execute `configure', you'll need to use
1 Bash 2.05 for all other build tasks as well.
1
1 Ksh
1 The Korn shell is compatible with the Bourne family and it mostly
1 conforms to Posix. It has two major variants commonly called
1 `ksh88' and `ksh93', named after the years of initial release. It
1 is usually called `ksh', but is called `sh' on some hosts if you
1 set your path appropriately.
1
1 Solaris systems have three variants: `/usr/bin/ksh' is `ksh88'; it
1 is standard on Solaris 2.0 and later. `/usr/xpg4/bin/sh' is a
1 Posix-compliant variant of `ksh88'; it is standard on Solaris 9
1 and later. `/usr/dt/bin/dtksh' is `ksh93'. Variants that are not
1 standard may be parts of optional packages. There is no extra
1 charge for these packages, but they are not part of a minimal OS
1 install and therefore some installations may not have it.
1
1 Starting with Tru64 Version 4.0, the Korn shell `/usr/bin/ksh' is
1 also available as `/usr/bin/posix/sh'. If the environment
1 variable `BIN_SH' is set to `xpg4', subsidiary invocations of the
1 standard shell conform to Posix.
1
1 Pdksh
1 A public-domain clone of the Korn shell called `pdksh' is widely
1 available: it has most of the `ksh88' features along with a few of
1 its own. It usually sets `KSH_VERSION', except if invoked as
1 `/bin/sh' on OpenBSD, and similarly to Bash you can require Posix
1 compatibility by running `set -o posix'. Unfortunately, with
1 `pdksh' 5.2.14 (the latest stable version as of January 2007)
1 Posix mode is buggy and causes `pdksh' to depart from Posix in at
1 least one respect, see ⇒Shell Substitutions.
1
1 Zsh
1 To detect whether you are running `zsh', test whether
1 `ZSH_VERSION' is set. By default `zsh' is _not_ compatible with
1 the Bourne shell: you must execute `emulate sh', and for `zsh'
1 versions before 3.1.6-dev-18 you must also set `NULLCMD' to `:'.
1 ⇒Compatibility (zsh)Compatibility, for details.
1
1 The default Mac OS X `sh' was originally Zsh; it was changed to
1 Bash in Mac OS X 10.2.
1