2 ms·
This article seems to have been started from the position of "I want `set -euo pipefail`" and the points are just geared towards it. And those options have big
by faho 5y ago
This article seems to have been started from the position of "I want `set -euo pipefail`" and the points are just geared towards it.
And those options have big issues!
`-e` ("errexit") can just kill a script for no obvious reason, and doesn't even give a good error to figure out what happened.
`-o pipefail` makes it worse by causing pipelines to sometimes fail depending on how much input was buffered - the classic example is `something | head -n 1`. It also doesn't give a proper error, and with errexit this kills the entire script.
`-u` is probably okay, but also triggers for `$1` and friends, so it basically requires you to write `${foo-}` everywhere. And if you've done that, you can still misspell your variable name.
See http://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail http://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail
- hedora 5y agoAnd, -x gives you a trace of what the script did before exiting, mostly solving the debugging issues you listed.