The most recent Shellshock, a vulnerability in the popular shell bash, got me to evaluate again the unique setup on Ubuntu/Debian. In this setup, script execution is not handled by bash, this job is carred out by dash, the Debian Almquist Shell. Meanwhile, bash is still used for the interactive shell since dash does not have autocomplete and history support.
One advantage of this setup is that you start to write your script taking into account that it will not be executed by bash only. This makes sense, it requires just a little effort to avoid certain bashisms and stay compatible to the POSIX syntax. I myself was pretty ignorant of this, assuming that bash is ubiquitous. After using dash for a while, I learn a couple of new tricks and I am happier than my scripts follow this standard best practice. While dash is more efficient in its execution, in most cases the difference is negligible and that was not my primary concern.
Linux users can get dash easily, it is one apt-get
or yum install
away. For OS X, it is easy enough to build it from its source, e.g.:
DASH_VERSION=0.5.8
DASH_FULLNAME=dash-${DASH_VERSION}
DASH_TARBALL=dash_${DASH_VERSION}.orig.tar.gz
DASH_DOWNLOAD=https://mirrors.kernel.org/debian/pool/main/d/dash/${DASH_TARBALL}
rm -rf ${DASH_TARBALL} ${DASH_FULLNAME}
curl -L ${DASH_DOWNLOAD} -o ${DASH_TARBALL}
tar xzf ${DASH_TARBALL}
cd ${DASH_FULLNAME}
./configure && make
sudo make install
Update: On OS X (these days known as macOS), it is advised to use a package manager to install and keep dash up-to-date. For example, Nix works well and installing dash is a matter of running nix-env -i dash
. Read also why Nix is awesome.
As for the interactive shell, my favorite these days is fish. It does not support every single feature of bash but it works very well. If you are desperate, you can still workaround what you miss from bash. And make sure you check out Oh My Fish! as well.
Whether you prefer bash or dash or fish, Unix shells are always fun to explore!