Shells: Bash, Dash, and Fish
Join the DZone community and get the full member experience.
Join For Freethe 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.7 dash_fullname=dash-${dash_version} dash_tarball=${dash_fullname}.tar.gz dash_download=http://gondor.apana.org.au/~herbert/dash/files/${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
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!
Published at DZone with permission of Ariya Hidayat, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
What I Learned From Crawling 100+ Websites
-
Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
-
What Is TTS and How Is It Implemented in Apps?
-
Does the OCP Exam Still Make Sense?
Comments