Difference between revisions of "Dash as /bin/sh"

From ArchWiki
Jump to: navigation, search
(Expanded article, added more instruction)
(Redirect to a page with a proper name)
(12 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category:Arch development (English)]]
#REDIRECT [[Dash]]
[http://en.wikipedia.org/wiki/Debian_Almquist_shell Dash] is a minimalist POSIX-complient shell. It can be much faster than Bash, and takes up less memory when in use. Most POSIX compliant scripts specify {{filename|/bin/sh}} at the first line of the script, which means it will run {{filename|/bin/sh}} as the shell, which by default in Arch is a symlink to {{filename|/bin/bash}}.
You can re-symlink {{filename|/bin/sh}} to {{filename|/bin/dash}}, which can increase system performance, but first you must verify that none of the scripts that aren't explicitly #!/bin/bash scripts are safely POSIX compliant and don't require any of Bash's features.
This article is for those who want to help [[dash]] become the new {{filename|/bin/sh}}.
From http://article.gmane.org/gmane.linux.arch.devel/11418:
*All install scripts must be sh-compatible (or we need a way of executing non-sh scripts, there is a bug open for that)
*Any daemon/init script is probably written for /bin/bash as our rc.conf and other initscripts files use bash arrays, so those need to be pointed correctly
==Identifying bashisms==
Features of bash that aren't included in Dash ('bashisms') will not work without being explicitly pointed to {{filename|/bin/bash}}. The following instructions will allow you to find any scripts that may need modification.
Install {{package AUR|checkbashisms}} from the [[AUR]].
===Common places to check===
*Installed scripts with a {{codeline|#!/bin/sh}} shebang:
$ find {,/usr}/bin -type f \
    -exec grep -q -- '^#!/bin/sh' {} \; \
    -exec checkbashisms -f -p {} +
*Package install scripts:
$ find /var/lib/pacman/local -mindepth 2 -type f -name install \
    -exec checkbashisms -f -p {} + 2>&1 |\
    grep -v -e '^you may get strange results' \
            -e 'does not appear to have a #! interpreter line;$'
*Initscripts and daemons:
$ find \
    /etc/rc.{conf,d,local{,.shutdown},multi,shutdown,single,sysinit} -type -f \
    -exec checkbashisms -f -p {} + 2>&1 |\
    grep -v -e '^you may get strange results' \
            -e 'does not appear to have a #! interpreter line;$'
==Relinking /bin/sh==
Once you have verified that it won't break any functionality, it should be safe to relink {{filename|/bin/sh}}. To do so use the following command (as root):
  ln -sfT /bin/dash /bin/sh
==Initscript status==
* The FD checks with {{codeline|test -t}} in {{filename|/etc/rc.d/functions}} do not work correctly with dash, breaking colored output as a result. See http://bugs.archlinux.org/task/19551?project=1&order=id&sort=desc (the patch does not address this issue in particular).
:* Try using {{codeline|test(1)}} instead of the dash builtin?
:* Is the problem specific to calls involving {{codeline|init(1)}}?

Latest revision as of 17:03, 24 October 2013

Redirect to: