Dash

Dash (Debian Almquist shell) is a modern POSIX-compliant implementation of /bin/sh (sh, Bourne shell).

Dash is not Bash compatible, but Bash tries to be mostly compatible with POSIX, and thus Dash.

Dash shines in:

  • Speed of execution. Roughly 4x times faster than Bash and others.
  • Very limited resources (disk space, RAM or CPU). As minimalistic as possible - much smaller (134.1 kB vs 6.5 MB installed, 13 kSLOC vs 176 kSLOC) than Bash and others.
  • Security. Dash is a long-established, tiny project with simple and long-established functionality; one that is still very much alive, and with many active developers. Thus, Dash has a much smaller attack surface, while still having many eyes on its code.
  • If classic /bin/sh needed only.

Installation

Install dash or dash-static-muslAUR.

Use Dash as /bin/sh

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.

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 are not explicitly #!/bin/bash require any of Bash's features and that all /bin/sh scripts are safely POSIX compliant.

Identifying bashisms

Features of bash that are not 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 .

Common places to check

  • Installed scripts with a shebang:
$ find /usr/bin/ -type f -perm -o=r -print0 | xargs -0r gawk '/^#!.*( |[/])sh/{printf "%s\0", FILENAME} {nextfile}' | xargs -0r checkbashisms
  • pacman -Qlq can be used to list all pacman-installed files.

Relinking /bin/sh

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

# ln -sfT dash /usr/bin/sh

Updates of Bash will overwrite /bin/sh with the default symlink. To prevent this, use the following pacman hook, which will relink /bin/sh after every affected update:

[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Target = bash

[Action]
Description = Re-pointing /bin/sh symlink to dash...
When = PostTransaction
Exec = /usr/bin/ln -sfT dash /usr/bin/sh
Depends = dash

This is provided by .

gollark: Besides, it is probably faster than most storage systems would be in the same situation. Except Artist, which is much better optimized.
gollark: 1. for some reason, it was turned on several times2. there were lots of NBT-having items so display name caching didn't work very well
gollark: It only lags lots in bizarre edge cases.
gollark: The reason is more "I'm quite lazy" and "this way it will be harder to handle the problems which do occur when my data model does not match reality".
gollark: Sure, but in this case the simple solution is probably just to make printed pages not get display names handled individually.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.