Difference between revisions of "Dash"

From ArchWiki
Jump to: navigation, search
m (How to make DASH default. Removed developers related notes (this is not a development page), and rc.conf ones.)
m (Typo.)
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
[[Category:Command shells]]
 
[[Category:Command shells]]
 
[[Category:Arch development]]
 
[[Category:Arch development]]
 
 
 
[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}}.
 
[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}}.
  

Revision as of 17:14, 24 October 2013

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

Installation

Install dash from the official repositories.

Use DASH as default shell

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#)

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#)

You can re-symlink /bin/sh to /bin/dash, which can improve 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.

Identifying bashisms

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

Install checkbashismsAUR from the AUR.

Common places to check

  • Installed scripts with a #!/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;$'

Relinking /bin/sh

Once you have verified that it won't break any functionality, it should be safe to relink /bin/sh. To do so use the following command:

# ln -sfT /bin/dash /bin/sh

Updates of Bash could overwrite /bin/sh. To prevent this, add the following line to the [option] section of /etc/pacman.conf:

NoExtract   = bin/sh

See also

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