Why would you not know what shell you run your script in?
- You are writing an installer script that must run on an unknown machine.
- You are writing a single script that will work with multiple known shells.
- Not all
bash
features work the same even across different versions ofbash
(see thecompat31
,compat32
,compat40
,compat41
options).
Some common examples of non-bash
usage:
dash
is the system shell for Debian and Ubuntu- Mac OS X continues to ship with
bash
3.2 instead of 4.x - Solaris uses, I believe, a version of
ksh
bash
needs to be installed separately on FreeBSD systems.