Shell execution options

1 min read

Source

set -e

Makes cmd1 && cmd2 && cmd3 equivalent to

set -e
cmd1
cmd2
cmd3

set -u

The shell prints a message to stderr when it tries to expand a variable that is not set. Also it immediately exits. An interactive shell will not exit.


set -x

The shell prints each command in a script to stderr before running it.


set -o pipefail

Pipelines fail on the first command which fails instead of dying later on down the pipeline. This is especially good when cmd3 is a command that always succeeds (like echo):

cmd1 | cmd2 | cmd3