Este é um comportamento documentado.
A página man do bash (1) diz, para set -e
,
The shell does not exit if the command that fails is part of the command list immediately following a
while
oruntil
keyword, part of the test following theif
orelif
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!
.
[Emphasis added.]
E a especificação POSIX Shell Command Language confirma que este é o comportamento correto:
The
-e
setting shall be ignored when executing the compound list following thewhile
,until
,if
, orelif
reserved word, a pipeline beginning with the!
reserved word, or any command of an AND-OR list other than the last.
e Seção 2.9.3 Listas desse documento define
An AND-OR list is a sequence of one or more pipelines separated by the operators "
&&
" and "||
" .