#!/bin/bash
set -euo pipefail
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]:
They have the following effects[2]:
Symbol | Effect |
---|---|
|
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. |
|
Treat unset variables and parameters other than the special parameters "@" and "*" as an error when performing parameter expansion. |
|
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
-
T. V. Eyck, “Safe bash scripts witih ’set -euxo pipefail.’” https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ , Mar-2015.
-
B. Fox and C. Ramey, “BASH(1) General Commands Manual.” Dec-2018.