Skip to content

Topic

Shell error handling

How shell scripts detect and report command failures, covering errexit, nounset, pipefail, ERR and EXIT traps, exit statuses and cleanup handlers.

Current clusters

build1 publisher

Adding -E made a silent ERR trap name the failing mkdir on line 5

Under set -euo pipefail, a failing mkdir inside a helper function killed a nine-line script while the ERR trap printed nothing. Adding one letter, -E, made the same trap report the command and the line it died on.

Publishers:dev.to

Reality

Evidence68
Adoption
Insufficient
Hype gap+8
Incentives45
Confidence66