News for hackers. Stuff that matters.
Re:Use the Unofficial Bash Strict Mode (Unless You Love Debu... by 1amzave on Friday March 18, 2016 @06:00PM (#11315530)
Fails to mention what is in my opinion the most devious, subtle potential pitfall with `set -e`: assigning (or even just a bare evaluation of) an arithmetic zero. `foo=0` won't do anything surprising, but `let foo=0` will return 1, and thus abort your script if you're not careful.

Also, as an alternative to the proposed `set +e; ...; set -e` wrapper for retrieving the exit status of something expected to exit non-zero (generally cleaner in my opinion, if slightly "clever"):

    retval=0
    count=$(grep -c some-string some-file) || retval=$?

There are no comments on this comment yet.