Dash#

dash, the Debian Almquist Shell. A minimal, fast, POSIX-compliant sh implementation. /bin/sh on Debian, Ubuntu, and many derivatives.

Purpose#

Dash exists to do one job: be the smallest, fastest, strictly POSIX shell that early-boot and init scripts can rely on. It deliberately omits the interactive niceties that make Bash and Zsh pleasant at a prompt, in exchange for measurable speedups when hundreds of /bin/sh invocations run during boot.

  • Small, ~150 KB binary, much less RAM than Bash.

  • Fast, system boot scripts run measurably faster.

  • POSIX-only, no Bashisms; what works in Dash works under POSIX.

That last property makes Dash a good test for portable scripts: if it runs under Dash, it’ll run under most sh implementations.

Distribution#

Dash is the /bin/sh you actually meet on most modern systems without realizing it. The Debian / Ubuntu lineage (and everything downstream of it) ships Dash as /bin/sh, so any portable script you write will probably run under Dash before any other shell.

  • Default ``/bin/sh`` on Debian since Squeeze (2011) and on Ubuntu since 6.10.

  • Available as a package on most other distros.

dpkg-reconfigure dash switches between Dash and Bash for /bin/sh on Debian-family systems.

Differences from Bash#

What Dash leaves out that Bash adds. The list below is short on purpose, if Dash had everything Bash has, it would not be much smaller or faster than Bash. Each missing feature has a portable workaround in plain POSIX:

  • No arrays.

  • No [[.

  • No advanced parameter expansion.

  • No $'...' ANSI-C quoting.

  • No process substitution.

  • echo doesn’t accept -e.

If a script works under Dash, it almost certainly works under any POSIX shell.

When You Care#

You don’t write Dash scripts directly; you write sh scripts and Dash is what runs them. The result is the same as targeting POSIX: if it works under Dash it works under almost everything else, and if it breaks under Dash a beginner will hit the same break the first time the script lands on Ubuntu:

  • Debian / Ubuntu init scripts.

  • Container entrypoints on Debian-based images.

  • The shellcheck -s sh and checkbashisms portability targets.

If a script starts with #!/bin/sh and breaks on Ubuntu but works under Bash, Dash is usually what’s flagging the difference.

Verifying Portability#

Three quick checks turn portability from “I hope it works” into something you can run from CI. Run the script under Dash, lint it with shellcheck in -s sh mode, and let checkbashisms flag the easy mistakes:

$ dash my-script.sh
$ shellcheck -s sh my-script.sh
$ checkbashisms my-script.sh

When to Use#

You almost never reach for Dash deliberately, it shows up because the distribution picked it. The decision facing the operator is what to target: write to Dash semantics and your script runs on every Unix; depend on Bashisms and you constrain yourself to systems that ship Bash.

  • You aren’t choosing it; the system chose it.

  • If you need to write portable shell scripts, target Dash semantics (POSIX) and you’ll work everywhere.

For interactive use, Dash is too bare; switch to Bash, Zsh, or Fish.