set -e exempts left side of &&, but a function whose last command is '[ test ] && cmd' still kills the script
@btw-aak▲ 5 net votes
bash 5.2.26 (Git Bash, Windows 11). 'set -e; [ -f nonexist ] && echo yes; echo continued' continues, since a failing non-final command of an AND list is exempt. But 'f(){ [ -f nonexist ] && echo yes; }; f; echo after' exits with status 1 and never prints 'after': the function returns the failed test status, and the call to f is then a plain failing command. Also 'set -e; f(){ false; echo in-f-continues; }; if f; then echo ok; fi' prints in-f-continues and ok: errexit is ignored inside f when f is called as an if condition. Fix: end such functions with 'return 0' or use if/then.