Hacker News new | ask | show | jobs
by Siecje 1940 days ago
set -e is not great and is not recommended. http://mywiki.wooledge.org/BashFAQ/105
4 comments

-e is in the class of things that can be fine to use, but the people least-likely to be prepared to know when it can be are the most likely to expect it to behave better than it does.

Sort of a combination finger-trap/cigar cutter for newbies.

Yeah.. but still useful despite the "false positives" that the link states which are addressable with proper error handling.
`-eu -o pipefail` catches most of what newcomers expect anyway.
I agree with the second to last recommendation:

> rking's personal recommendation is to go ahead and use set -e, but beware of possible gotchas. It has useful semantics, so to exclude it from the toolbox is to give into FUD.

Manual error handling would be ideal but it's too easy for me to mess up and miss something. Plus, if you really wanted to catch everything with proper error handling you would need to wrap every command in your script.

I read this as "bash has unintuitive footguns" rather than "set -e has unintuitive footguns with its usage".
Bash doesn't have unintuitive footguns, bash <<is>> a unintuitive footgun :-)
Agree with the "false positives" however in combination with error handling I don't see why not use it.