What’s wrong with my script?
Are you receiving syntax errors when running a shell script on Ubuntu 6.10 (Edgy Eft)? If so, you might want to check what shell you are using. While testing scripts for the LCA A/V Team a few months ago, I discovered that the Ubuntu developers decided to symlink /bin/sh to dash, for faster and less memory-intensive script execution. For POSIX-compliant scripts, this isn’t a problem at all. However, there are many third-party scripts which call /bin/sh but use shell-specific (typically bash) syntax. They can be fixed by altering their first line to call the most appropriate shell, for example:
#!/usr/bin/env bash
env makes it possible to call bash, wherever it may lie. While my Ubuntu and Gentoo systems have a /bin/bash, there are other distributions which have /usr/bin/bash or /usr/local/bin.bash.
While you can and should fix your own scripts to operate in this way, constantly mending others’ mistakes can become tiresome. You can return your /bin/sh to point to bash with the following command:
$ sudo dpkg-reconfigure dash
When asked if you wish to install dash as /bin/sh, tell it to go to hell 
Note that bash does use more memory, but on a modern desktop machine the difference is negligible. This change will not affect the default login shell, since that is already bash.


I’d prefer people file bugs against either the Ubuntu or Debian packages when they encounter problems like this. By all means hack the script to point to /bin/bash in the meantime, but please file a bug so someone can fix the script to not contain bashisms, or exec /bin/bash.
Comment by Steve Kowalik — April 1, 2007 @ 12:18 am
Tiresome it may be, but it’s also the only way forward. If all these scripts aren’t fixed, upstream, then the next person will also have problems with it. And the next, and the next. And not only on Debian and Ubuntu, but on any system that may ship with another default. Don’t give up, file bugs!
Comment by Stoffe — April 1, 2007 @ 12:38 am
I think I remember reading that switching to Dash sped up the average start up time by 3-4 seconds, so I wouldn’t advocate changing the default unless you run into the shell mismatch problem a significant number of times.
Comment by Stu Hood — April 1, 2007 @ 3:00 am