set -e

The shell option that makes a script exit as soon as a command fails, instead of carrying on.

In more detail

It ignores failures that are already handled: commands tested by if, while or until, anything on the left of || or &&, and non-final pipeline stages unless pipefail is on. local x=$(cmd) also hides the failure, because local itself succeeds. Treat it as a seatbelt and still check the statuses you care about.

Example

set -euo pipefail

Related terms

Taught in

References