# info > sh

---
type: CommandReference
command: dash
mode: man
section: 1
source: man-pages
---

## Quick Reference

- `dash script.sh` — run a shell script
- `dash -c "command"` — execute a command string
- `dash -i` — interactive shell
- `dash -n script.sh` — syntax check without execution
- `dash -x script.sh` — debug execution trace
- `dash -u` — treat unset variables as error
- `dash -e` — exit on error if any untested command fails
- `dash -s` — read commands from stdin

## Name

dash — command interpreter (shell)

## Synopsis

shell
dash [-aCefnuvxIimqVEbp] [+aCefnuvxIimqVEbp] [-o option_name] [+o option_name] [command_file [argument ...]]
dash -c [-aCefnuvxIimqVEbp] [+aCefnuvxIimqVEbp] [-o option_name] [+o option_name] command_string [command_name [argument ...]]
dash -s [-aCefnuvxIimqVEbp] [+aCefnuvxIimqVEbp] [-o option_name] [+o option_name] [argument ...]
## Options

Options can be set from the command line or with the `set` builtin. A dash `-` enables the option, a plus `+` disables it.

- `-a, -o allexport` — Export all variables assigned to.
- `-b, -o notify` — Enable asynchronous notification of background job completion. (UNIMPLEMENTED)
- `-C, -o noclobber` — Don't overwrite existing files with `>`.
- `-e, -o errexit` — If not interactive, exit immediately if any untested command fails.
- `-f, -o noglob` — Disable pathname expansion.
- `-i, -o interactive` — Force the shell to behave interactively.
- `-l` — Make dash act as if invoked as a login shell.
- `-m, -o monitor` — Turn on job control (automatically set when interactive).
- `-n, -o noexec` — If not interactive, read commands but do not execute them (syntax check).
- `-p, -o privileged` — Do not reset effective uid if it does not match uid. Avoids incorrect usage by setuid programs via `system(3)` or `popen(3)`.
- `-s, -o stdin` — Read commands from standard input (automatically set if no file arguments).
- `-u, -o nounset` — Write to stderr when expanding an unset variable; if not interactive, exit immediately.
- `-v, -o verbose` — Write input to stderr as it is read.
- `-x, -o xtrace` — Write each command to stderr (preceded by `+ `) before execution.
- `-E, -o emacs` — Enable built-in emacs command line editor (disables `-V`).
- `-I, -o ignoreeof` — Ignore EOFs from input when interactive.
- `-V, -o vi` — Enable built-in vi command line editor (disables `-E`).
- `-o option_name` — Set option by name (e.g., `-o vi`).
- `+o option_name` — Unset option by name.

## Examples

**Pipeline with redirection:**

shell
$ command1 2>&1 | command2
Sends both stdout and stderr of command1 to stdin of command2.

**Here-document:**

shell
$ cat << EOF
This is a here-document
EOF
**Flow control: if/while/for/case**

shell
if [ -f file ]; then
    echo "file exists"
fi
shell
for i in 1 2 3; do
    echo $i
done
**Function definition:**

shell
myfunc() {
    echo "hello $1"
}
**Command substitution:**

shell
echo "Today is $(date)"
**Background command:**

shell
sleep 10 &
## See Also

[csh(1)](http://localhost/phpMan.php/man/csh/1/markdown), [echo(1)](http://localhost/phpMan.php/man/echo/1/markdown), [getopt(1)](http://localhost/phpMan.php/man/getopt/1/markdown), [ksh(1)](http://localhost/phpMan.php/man/ksh/1/markdown), [login(1)](http://localhost/phpMan.php/man/login/1/markdown), [printf(1)](http://localhost/phpMan.php/man/printf/1/markdown), [test(1)](http://localhost/phpMan.php/man/test/1/markdown), [getopt(3)](http://localhost/phpMan.php/man/getopt/3/markdown), [passwd(5)](http://localhost/phpMan.php/man/passwd/5/markdown), [environ(7)](http://localhost/phpMan.php/man/environ/7/markdown), [sysctl(8)](http://localhost/phpMan.php/man/sysctl/8/markdown)

## Exit Codes

Errors detected by the shell (e.g., syntax error) cause a non-zero exit status. In non-interactive mode, the shell script aborts. Otherwise, the shell returns the exit status of the last command executed, or the argument given to the `exit` builtin.