On Thu, Dec 08, 2016 at 09:04:46PM +0300, vi0oss wrote: > Why Git test use &&-chains instead of proper "set -e"?
Because "set -e" comes with all kinds of confusing corner cases. Using && chains is annoying, but rarely surprising. One of my favorite examples is: set -e ( false echo 1 ) || { echo outcome=$? false } echo 2 which prints both "1" and "2". Inside the subshell, "set -e" has no effect, and you cannot re-enable it by setting "-e" (it's suppressed entirely because we are on the left-hand side of an || conditional). So you could write a function like this: foo() { do_one do_two } that relies on catching the failure from do_one. And it works here: set -e foo but not here: set -e if foo then do_something fi And there's no way to make it work without adding back in the &&-chaining. -Peff