Referencing 27 ‘set’ options in Bash
The aim of this page📝 is to list all 27 options one can use in combination with the `set` command in Bash.
1 min readMar 11, 2024
use set -<opt>
to activate and set +<opt>
to deactivate option
- one possibility is to use
set -o <option_name>
for example - another is to use a flag of the option
set -<flag>
referencing 27 options of set
examples
errexit
(or e
) - Exit immediately if a command exits with a non-zero status.
set -o errexit
# or
set -e
nounset
(or u
) - Treat unset variables as an error when expanding them.
set -o nounset
# or
set -u
pipefail
- Return the exit status of the last command in a pipeline.
set -o pipefail
noclobber
- Prevent overwriting files with >
and >|
redirection.
set -o noclobber
set -C
noglob
- Disable pathname expansion (globbing).
set -o noglob
# or
set -f
xtrace
(or x
) - Print commands and their arguments as they are executed.
set -o xtrace
# or
set -x