|
|
|
|
|
by matvore
1863 days ago
|
|
`set -e` has a couple of surprising corner cases and in the details is pretty hard to understand. The documentation in `man bash` for the `set -e` flag is 28 lines in my terminal, and the other flags are 2 or 3 lines. One such corner case is in pipelines. Only the last command in a pipeline can cause the script to terminate. Another corner case is `foo && bar`, often used as an abbreviated `if`, will not exit when `foo` fails. It is not a significant task to just add `|| exit $?` after any command whose failure should cause an abort. |
|
set -euo pipefail
This addresses the pipeline case you mention and also notices use of unitialized variables.