source
.
In lieu of that, here's how or
works:
In the simple case:
foo
or bar
if foo
failed, fish moves on to the or
, which checks $status. This is similar to
foo
if test $status -ne 0
bar
end
This is all very easy and fine and dandy, there is however a special case. In if
or while
conditions, the or
binds the command to the condition instead of going into the block:
if foo; or bar
echo hello
end
will print hello
if foo succeds, and will also print hello if foo fails and the subsequent bar succeeds. If both foo and bar fail, it won't print.
This isn't 1000% clean, but the alternative of making or
just that simple shortcut is that you now need to write
if begin; foo; or bar; end
which is just annoying (and yes, that used to be the case up to fish ~2.3)
I'm assuming you meant the latter by "member of the block to execute", and so the answer is: Because it was annoying otherwise, so we changed it.
Because the other behavior might be "clean" from a theoretical standpoing, but also 100% useless:
if foo
if test $status -ne 0
bar
end
echo hello
end
Here, to get to the bar
, foo
would have to fail. But once it fails the if-block won't be entered anymore, so that bar
is unreachable! It can't be used! It's dead!