Bash

Features

set

set modifies the behavior of bash in specific ways.

See man bash for further details.

Options

The following set options by default in bash scripts[1]:

#!/bin/bash

set -euo pipefail

They have the following effects[2]:

Symbol Effect

e

Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command (see SHELL GRAMMAR above), exits with a non-zero status.

u

Treat unset variables and parameters other than the special parameters "@" and "*" as an error when performing parameter expansion.

-o pipefail

If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully.

Linters

References

  1. T. V. Eyck, “Safe bash scripts witih ’set -euxo pipefail.’” https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ , Mar-2015.

  2. B. Fox and C. Ramey, “BASH(1) General Commands Manual.” Dec-2018.

Found a bug? Got a correction? You can edit this page on GitHub