Dash#

The Debian Almquist Shell. Dash is the default /bin/sh on Debian-family distributions and is built for script execution speed, not interactive use. Stock dash links against the kernel read() syscall directly and does not include a line editor: no readline, no history, no completion, no Ctrl-r. What the operator sees at an interactive dash prompt is whatever the terminal driver provides.

For a comfortable interactive shell, use bash, zsh, or fish. Reach for dash when measuring script-start overhead, validating POSIX-only behaviour, or running on an embedded target where size matters.

Terminal Driver#

The terminal driver (stty) provides the only line editing dash sees. These are POSIX special characters, set per-terminal and overridable with stty <name> <key>. stty -a prints every current setting.

Key

Action

Backspace (erase)

erase the previous character on the current line

Ctrl-u (kill)

erase the whole line (terminal-driver erase, not a shell widget)

Ctrl-w (werase)

erase the previous word (whitespace-delimited)

Ctrl-c (intr)

send SIGINT to the foreground process

Ctrl-\ (quit)

send SIGQUIT to the foreground process (core dump)

Ctrl-z (susp)

send SIGTSTP (suspend) to the foreground process

Ctrl-d (eof)

send EOF; on an empty line, exits the shell

Ctrl-s (stop)

pause terminal output (XOFF)

Ctrl-q (start)

resume terminal output (XON)

Ctrl-r (rprnt)

reprint the current line (terminal driver, not history)

Ctrl-v (lnext)

take the next character literally (escape control characters)

What Does NOT Work#

Reflexes from bash / zsh that produce no result in interactive dash.

Key

Result in dash

Up / Down

prints raw escape sequence (^[[A) into the input

Left / Right

prints raw escape sequence; cursor does not move

Tab

inserts a literal tab character

Ctrl-r

reprints the line (terminal driver), no history search

Ctrl-a / Ctrl-e

inserted as raw control characters

Alt-<key>

inserted as Esc + key

!! / !$

no history expansion (POSIX history is opt-in; dash has none)

Workarounds#

To make dash usable interactively, wrap it in a line-editor front-end.

Command

Action

rlwrap dash

readline-style editing and per-program history

rlwrap -H ~/.dash_history dash

persistent history file

rlwrap -c dash

filename completion on Tab

socat readline exec:dash

similar wrapper via socat

ledit dash

lightweight line-editor wrapper (less common)

stty -a

print every terminal-driver setting

stty erase '^H'

set Backspace to send Ctrl-H

stty werase '^W'

set the word-erase character

stty sane

reset all settings to defaults after a stuck terminal

References#

  • man 1 dash, man 1p sh (POSIX shell).

  • man 1 stty, man 7 termios (the terminal driver underneath every shell).

  • Dash for /bin/sh usage details.