On Fri, Dec 22, 2017 at 10:56:18AM -0800, Kevin Layer wrote: > The man page says: > > The shell does not exit if the command that fails is part of the > command list immediately following a while or until keyword, > part of the test following the if or elif reserved words, > part of any command executed in a && or || list except the > command following the final && or ||, any command in a > pipeline but the last, or if the command's return value is being > inverted with !. > > The fact that [ exits with 1 seems to be covered by the above passage for > -e.
[ exits 1, but this doesn't trip -e because it's part of a compound command. However, debug1 also exits 1, and THAT trips -e, because debug1 is a simple command. debug2 does not exit 1 because "if" has completely different rules compared to compound commands strung together with &&. wooledg:~$ if false; then echo hi; fi wooledg:~$ echo $? 0 wooledg:~$ false && echo hi; echo $? 1