3 ms·
I always put set -euxo pipefail at the top of my bash scripts. It makes some conditional testing more difficult but it has paid for itself many times over jus
by klysm 3y ago
I always put
set -euxo pipefail
at the top of my bash scripts. It makes some conditional testing more difficult but it has paid for itself many times over just because of pipefail
- ddlsmurf 3y agoYou can also set it for a bunch of lines then deactivate it with `set +x`. It gets rather tedious otherwise...
- mellutussa 3y agoThis is a lifesaver. Although I save the -x until I really need to see all the garbage debug output.
- klysm 3y agoI find it’s usually worth the noise to catch weirdness
- mrAssHat 3y agohttps://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail https://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail
- klysm 3y agoThanks for the reference! Seems like a really good resource. I disagree with the reasoning about pipefail though. If I expect a command to return non-zero exit code I'd rather be explicit about it.