Dash as /bin/sh

For those of you, who would like to set the dash shell as the default system shell instead of bash, as it was done in Debian and Ubuntu already a long time ago:

sudo pacman -S dash
sudo mv /bin/sh /bin/sh_old
sudo ln -sfn dash /bin/sh

This does not change your login shell, the shell that actually appears, when you open a terminal as a user (changing the login shell is done with 'chsh')

In order to revert to bash:

sudo rm /bin/sh
sudo mv /bin/sh_old /bin/sh

But why should anybody want to do that?

The dash is actually the Linux port of the ash, the Almquist Shell. The Almquist Shell was designed with POSIX compatibility and low resource use in mind. When Ubuntu moved to dash in 2006, they just wanted to speed up init scripts and automated processes. On the way there they found out that many scripts used bash specific elements, which are not POSIX compatible. These elements were called bashisms. Ubuntu then decided to remove these bashisms, with compatibility in mind. The Rosettacode project states "If a script works with Almquist Shell, it will probably also work with bash, pdksh and zsh. Further, it will probably work with ksh93 unless it uses local, which ksh93 lacks." (https://rosettacode.org/wiki/Almquist_Shell)

Now, as Ubuntu's shift to dash was done 10 years ago and also Debian chose the dash as it's /bin/sh a long time ago, the cleanups of shellscripts containing bashisms went upstream, thus they are available now in general. A few days ago I set the /bin/sh on my Manjaro to dash. And guess what — it works!

For further information:



A well done overview about the variations and the history of the Almquist Shell:

I wonder if I could package this. Dash-to-sh. Depends on dash. Does not install anything, but has install script that runs on install

mv /bin/sh /bin/sh_old
ln -sfn dash /bin/sh

And on uninstall

rm /bin/sh
mv /bin/sh_old /bin/sh

Then I could put it in the bspwm edition...

You realize that /bin/sh is merely a link to /bin/bash in Manjaro right?

It does operate (slightly) differently when called via sh but it is the same executable.

Seems we only really have one shell in the default Manjaro install.

I know, I'm just figuring out how to switch the default for a specific edition in netinstall installer.

Bspwm edition ships with bash, dash, zsh and fish. Dash is used for most of the custom scripts and sxhkd, fish and zsh for interactive use and bash is just there because so many things required it.

Forum kindly sponsored by