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

From ArchWiki
Jump to: navigation, search
(Identifying bashisms)
(Expanded article, added more instruction)
Line 2: Line 2:
 
{{expansion}}
 
{{expansion}}
 
{{accuracy}}
 
{{accuracy}}
 +
 +
[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}}.
 
This article is for those who want to help [[dash]] become the new {{filename|/bin/sh}}.
Line 13: Line 17:
  
 
==Identifying bashisms==
 
==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]].
 
Install {{package AUR|checkbashisms}} from the [[AUR]].
Line 35: Line 41:
 
     grep -v -e '^you may get strange results' \
 
     grep -v -e '^you may get strange results' \
 
             -e 'does not appear to have a #! interpreter line;$'
 
             -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==
 
==Initscript status==

Revision as of 18:38, 17 August 2011

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Dash as /bin/sh#)

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Dash as /bin/sh#)

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 Template:Filename at the first line of the script, which means it will run Template:Filename as the shell, which by default in Arch is a symlink to Template:Filename.

You can re-symlink Template:Filename to Template:Filename, 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 Template:Filename.

From http://article.gmane.org/gmane.linux.arch.devel/11418:

Identifying bashisms

Features of bash that aren't included in Dash ('bashisms') will not work without being explicitly pointed to Template:Filename. The following instructions will allow you to find any scripts that may need modification.

Install Template:Package AUR from the AUR.

Common places to check

$ 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 Template:Filename. To do so use the following command (as root):

 ln -sfT /bin/dash /bin/sh

Initscript status