dash
Execute shell scripts
TLDR
Start an interactive shell session
Execute specific [c]ommands
Execute a specific script
Check a specific script for syntax errors
Execute a specific script while printing each command before executing it
Execute a specific script and stop at the first [e]rror
Execute specific commands from stdin
SYNOPSIS
dash [options] [script-file [arguments]]
dash -c command_string [command_name [arguments]]
dash -s [arguments]
PARAMETERS
-c command_string
Reads commands from the provided command_string instead of a file or standard input.
-s
Reads commands from standard input. This is the default if no file is specified and standard input is a terminal.
-i
Forces the shell to run in interactive mode, even if standard input/output are not terminals.
-l
Makes dash
act as a login shell. This usually involves reading specific startup files.
-n
Reads commands but does not execute them. This option is useful for checking the syntax of shell scripts.
-v
Prints shell input lines as they are read. Useful for debugging scripts.
-x
Prints commands and their arguments as they are executed. This is a common debugging aid.
-u
Treats unset variables as an error. An attempt to expand an unset variable will cause the shell to exit with an error.
--help
Displays usage information for the dash
command.
--version
Prints the dash
shell version information.
DESCRIPTION
dash (Debian Almquist SHell) is a modern, lightweight, POSIX-compliant command interpreter. It is a derivative of the original Almquist shell (ASH), designed specifically for speed and minimal resource consumption. This makes it an ideal choice for executing system scripts efficiently.dash
is often the default /bin/sh
on Debian and Ubuntu systems, replacing bash
for this critical role. Its primary advantages include significantly faster startup times and a lower memory footprint compared to bash
, which contributes to quicker system boots and more efficient execution of numerous small scripts.
While highly optimized for non-interactive script execution, dash
lacks many user-friendly interactive features (like advanced command history, tab completion, or extensive globbing) found in bash
. Its strict adherence to the POSIX standard ensures high portability for scripts written against it, but also means scripts relying on bash-specific extensions (bashisms) will likely fail.
CAVEATS
- Bashisms Incompatibility:
dash
strictly adheres to POSIX standards. Scripts written specifically forbash
that utilize bash-specific features (e.g.,[[ ... ]]
for conditional expressions, process substitution<()
, certain array manipulations, non-standard globbing) will likely fail or behave unexpectedly when executed bydash
. - Limited Interactive Features: Unlike feature-rich shells like
bash
orzsh
,dash
offers minimal interactive capabilities. It lacks advanced command history, tab completion, prompt customization, and other conveniences expected by interactive users. It is primarily designed for script execution. - Debugging Complexity: Due to its minimalistic nature, debugging complex scripts can sometimes be more challenging in
dash
compared tobash
, which offers more sophisticated introspection tools.
PERFORMANCE AND RESOURCE EFFICIENCY
dash
is engineered for speed and minimal memory footprint. Its lean design means it starts up significantly faster and consumes fewer resources than bash
, making it highly efficient for running numerous small system scripts, especially those executed during system boot or in resource-constrained environments. This contributes to quicker system startup times and overall lower system load.
POSIX COMPLIANCE AND SCRIPT PORTABILITY
A core tenet of dash
is its strict adherence to the POSIX.1-2001 and POSIX.1-2008 standards. This strong compliance ensures that scripts written using only POSIX-specified features will execute predictably and portably across different Unix-like systems. However, this also means that scripts containing bash
-specific syntax or extensions (often called "bashisms") will fail or behave incorrectly when executed by dash
, highlighting the importance of writing POSIX-compliant shell scripts for maximum compatibility.
PRIMARY USE CASE: SYSTEM SCRIPTING VS. INTERACTIVE USE
While dash
can be used interactively, its primary design goal and optimal use case is non-interactive execution of system scripts. For daily interactive shell usage, most users prefer feature-rich shells like bash
or zsh
due to their extensive capabilities such as advanced command history, tab completion, sophisticated prompt customization, and interactive debugging features. dash
focuses on providing a robust, fast, and reliable interpreter for automated tasks.
HISTORY
dash
is a direct descendant of the Almquist shell (ASH), originally developed by Kenneth Almquist in the late 1980s. ASH was known for its small size and speed. It was adopted by NetBSD and later FreeBSD as their /bin/sh
due to its efficiency and POSIX compliance.
The Debian Almquist SHell (dash
) was developed specifically for Debian, stemming from the NetBSD version of ASH. In 2006, Debian made a significant change, switching the default /bin/sh
symlink from bash
to dash
. This decision was primarily driven by the desire for faster boot times and reduced memory usage for system scripts, which are frequently executed during startup and throughout system operation. Ubuntu followed suit shortly thereafter. This transition sometimes revealed "bashisms" in scripts that were implicitly relying on bash
features.