Exercise 6:
set -e
f() { false; echo survived; }
if ! f; then :; fi
That one was fun to learn.
Even with all the jank and unreliability, I think set -e
does still have some value as a last resort for preventing unfortunate accidents. As long as you don’t use it for implicit control flow, it usually (exercise 6 notwithstanding) does what it needs to do and fails early when some command unexpectedly returns an error.
>buys game on steam
>game installs and executes Origin on launch
>Origin launches actual game
Ok, I didn’t buy the game on a clown launcher. Now what?