set -eu
sh -euc 'echo 1; false; echo 2' || echo fail
f() {
echo 1
false
echo 2
}
{ echo 1; false; echo 2; } || echo fail
( echo 1; false; echo 2; ) || echo fail
f || echo fail
Output (at least in sh
, ash
, bash
):
1
fail
1
2
1
2
1
2
Is this the expected behavior? Can you possibly explain this particular case? Why does it work this way? Is sh -c
the only workaround?