On Tue, Feb 11, 2025, at 9:18 AM, Greg Wooledge wrote: > Look at the definition of set -e: > > -e Exit immediately if a pipeline (which may consist of a > single simple command), a list, or a compound command > (see SHELL GRAMMAR above), exits with a non-zero status. > 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 !.
Here's the corresponding POSIX description (search for "-e"): https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_26 Other shells behave this way too: $ cat /tmp/foo.sh set -e false && echo unreachable echo reached $ bash /tmp/foo.sh # bash 5.2.37 reached $ dash /tmp/foo.sh # dash 0.5.12 reached $ /bin/ksh /tmp/foo.sh # ksh93u+ 2012-08-01 reached $ ksh /tmp/foo.sh # ksh93u+m/1.0.10 2024-08-01 reached $ mksh /tmp/foo.sh # mksh R59 2020/10/31 reached $ oksh /tmp/foo.sh # OpenBSD 7.6 pdksh reached $ yash /tmp/foo.sh # yash 2.57 reached -- vq