๐ง Dash
Dash is a lightweight, fast, strictly POSIXโcompliant shell used as /bin/sh on Debian and Ubuntu.
It is optimized for speed, correctness, and minimalism, making it ideal for system scripts and automation.
๐ Who This Is For
- Engineers writing portable
/bin/shscripts - DevOps/SRE teams maintaining Debian/Ubuntu systems
- CI/CD authors targeting minimal runners
- Developers migrating bash scripts to POSIX sh
๐งฉ Role in the Ecosystem
- Default
/bin/shon Debian and Ubuntu - Used for system startup scripts and maintenance tasks
- Common in CI/CD environments based on Debian images
- Acts as a portability validator (bashisms fail fast)
๐งฉ Key Characteristics
- Very fast startup time
- Strict POSIX compliance
- Minimal feature set
- No arrays, no
[[ ]], no process substitution - Predictable behavior across environments
๐ง Notable Features
- Pure POSIX test syntax:
1 2 3 | |
-
Efficient pipeline execution: Dash is significantly faster than bash for shortโlived scripts.
-
Lightweight function definitions:
1 2 3 | |
โ ๏ธ Limitations & Pitfalls
- No bashโspecific features (arrays,
[[ ]], brace expansion, etc.) - No process substitution (
<( )) - No associative arrays
- Some GNU tools behave differently than expected
- Bash scripts often break silently when run under dash
๐ง When to Use Dash
- System scripts intended for
/bin/sh - CI/CD pipelines requiring speed and portability
- Automation on Debian/Ubuntu systems
- Scripts that must run in minimal environments
โ When Not to Use Dash
- Scripts requiring bash extensions
- Complex logic involving arrays or advanced pattern matching
- Interactive workflows (bash/zsh are better)
โ Best Practices
- Use
#!/bin/shfor POSIX scripts - Test explicitly under dash:
1 | |
- Avoid bashisms (
[[ ]], arrays,${var//pattern/repl}) - Keep scripts simple and predictable
- Validate portability using dash as the reference shell
๐งช Testing Dash Scripts
1 2 | |
๐ง Summary
Dash is the fast, strict, POSIXโcompliant /bin/sh used on Debian and Ubuntu.
If your script runs correctly under dash, it is portable, predictable, and suitable for production automation.