On Tue, Jul 5, 2022, at 6:34 PM, Yair Lenga wrote: > I probably did not described the intended behavior clearly. I believe > both cases should behave identical under errfail. The loop will ‘break’ > on the first iteration (false when word = a). Same for the all looping > commands. I believe this is consistent with if-then-else-if, when an > error in the then or else block will result in terminating (‘breaking’) > the if.
It's only consistent if your notion of consistency is "terminate all compound commands immediately". This kind of works for "if" but changes "for" and "while" in a very fundamental way. Your initial description of "treat a; b; c like a && b && c" implies that if condition; then a; b; c; fi should behave like if condition; then a && b && c; fi and for word in words; do a; b; c; done should behave like for word in words; do a && b && c; done but it turns out what you apparently want is for word in words; do a && b && c || ! break; done which is a larger change than you let on. -- vq