I thought /bin/sh
was a symlink to my shell of choice. I've always used bash
, so I assumed that /bin/sh
would point to /bin/bash
. It turns out, though, that it points to /bin/dash
.
It gets funnier. I start dash
and do echo $SHELL
and it prints /bin/bash
(so they're basically the same?). However, the man page of dash
is completely different from the man page of bash
(so they're not the same?).
Debian and Ubuntu switched to dash (iirc) because of a couple of things. First of all, Bash has become big over the years. In fact, the
/bin/bash
binary on my Ubuntu 8.04 system is almost ten times (!) as big as/bin/dash
. Now, that does not matter much for day to day shell use, but it does matter in the following situations:The downside of using Dash instead of Bash for scripting, is that a lot of people use syntactical niceties only Bash has, the so-called Bashisms. Examples of Bashisms are substrings, like this:
And this:
Dash, on the other hand mainly aims to be POSIX compliant (and no more than that), will give you a Bad substition error if you try this:
This will matter if you use
/bin/sh
(and thereforedash
) as the interpreter for your shellscripts and use Bashisms in them. Debian and Ubuntu have nice wiki pages about Bashisms and why they are bad in shellscripts in general and init-scripts in particular. Therefore, you should consciously choose whether you need/bin/sh
or/bin/bash
as the interpreter for your script.Dash is not supposed to be used as the default shell on your systems. Just use Bash for that. For portability of your scripts, you can use Dash as the interpreter to increase the odds the scripts will run on other Linux flavors and Unixes.
Take a look here: https://wiki.ubuntu.com/DashAsBinSh maybe It will help.
dash is a lightweight bash replacement, im assuming you use ubuntu which changed to it a few years ago.
Its not overly good though, imho. http://forums.debian.net/viewtopic.php?f=20&t=45116
Since not all shells set
$SHELL
when run, you find out your current shell with:If it gives an error, it's csh, otherwise it's the
argv[0]
you were invoked with, which is typically the shell, perhaps with a leading-
hyphen, to indicate that it's a login shell.This isn't guaranteed, since
argv[0]
is under the control of the invoking process, but it is in practice the most reliable approach.