https://wiki.archlinux.org/api.php?action=feedcontributions&user=Cdated&feedformat=atomArchWiki - User contributions [en]2024-03-28T23:08:28ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Dash_as_/bin/sh&diff=222187Dash as /bin/sh2012-09-09T07:09:52Z<p>Cdated: </p>
<hr />
<div>[[Category:Arch development]]<br />
{{expansion}}<br />
{{accuracy}}<br />
<br />
[http://en.wikipedia.org/wiki/Debian_Almquist_shell Dash] is a minimalist POSIX-compliant shell. It can be much faster than Bash, and takes up less memory when in use. Most POSIX compliant scripts specify {{ic|/bin/sh}} at the first line of the script, which means it will run {{ic|/bin/sh}} as the shell, which by default in Arch is a symlink to {{ic|/bin/bash}}.<br />
<br />
You can re-symlink {{ic|/bin/sh}} to {{ic|/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 do not require any of Bash's features. <br />
<br />
This article is for those who want to help [[dash]] become the new {{ic|/bin/sh}}.<br />
<br />
From http://article.gmane.org/gmane.linux.arch.devel/11418:<br />
*http://mailman.archlinux.org/pipermail/arch-dev-public/2007-November/003053.html<br />
*https://launchpad.net/ubuntu/+spec/dash-as-bin-sh<br />
*https://wiki.ubuntu.com/DashAsBinSh<br />
*All install scripts must be sh-compatible (or we need a way of executing non-sh scripts, there is a bug open for that)<br />
*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<br />
<br />
==Identifying bashisms==<br />
<br />
Features of bash that aren't included in Dash ('bashisms') will not work without being explicitly pointed to {{ic|/bin/bash}}. The following instructions will allow you to find any scripts that may need modification. <br />
<br />
Install {{AUR|checkbashisms}} from the [[AUR]].<br />
<br />
===Common places to check===<br />
<br />
*Installed scripts with a {{Ic|#!/bin/sh}} shebang:<br />
$ find {,/usr}/bin -type f \<br />
-exec grep -q -- '^#!/bin/sh' {} \; \<br />
-exec checkbashisms -f -p {} +<br />
<br />
*Package install scripts:<br />
$ find /var/lib/pacman/local -mindepth 2 -type f -name install \<br />
-exec checkbashisms -f -p {} + 2>&1 |\<br />
grep -v -e '^you may get strange results' \<br />
-e 'does not appear to have a #! interpreter line;$'<br />
<br />
*Initscripts and daemons:<br />
$ find \<br />
/etc/rc.{conf,d,local{,.shutdown},multi,shutdown,single,sysinit} -type f \<br />
-exec checkbashisms -f -p {} + 2>&1 |\<br />
grep -v -e '^you may get strange results' \<br />
-e 'does not appear to have a #! interpreter line;$'<br />
<br />
==Relinking /bin/sh==<br />
Once you have verified that it won't break any functionality, it should be safe to relink {{ic|/bin/sh}}. To do so use the following command (as root):<br />
<br />
ln -sfT /bin/dash /bin/sh<br />
<br />
==Initscript status==<br />
<br />
* The FD checks with {{Ic|test -t}} in {{ic|/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).<br />
:* Try using {{Ic|test(1)}} instead of the dash builtin?<br />
:* Is the problem specific to calls involving {{Ic|init(1)}}?</div>Cdated