There's a few issues with this that causes this behavior:
The way "or" works, it waits until the first command has been executed,
then moves on to the second. The "if" only seems to be taking the first
command, and the "or" is actually being executed inside the block:
if false;
or true;
echo yes;
..
So, first `false` is being evaluated to.. false, then it is skipping
right to the "else" block. Therefore, the output is "no".
In the case you would want to make sure the "or" applies in the first
statement, you should use parentheses:
set myTest (false; or true)
echo $status # 0
set myTest (false; or false)
echo $status # 1
set myTest (true; or false) # note: the second "false" is not evaluated
because the true was already true.
echo $status # 0
if $myTest; #...
Also, one other thing to mention: the `test` command has an -o (or) and
-a (and) switch, made for using these operators (though I can't figure
out how they work, I seem to be receiving weird results and thus can't
provide and example... test (false) -o (false) has an exit status of 0
for me). Maybe it will help for what you're doing, it seems to be more
aimed at making tests for things like that.
Hope it helps,
nasonfish
On Sat, Dec 7, 2013 at 12:19 PM, Nick Mapsy <nma...@gmail.com> wrote:
Hi, I'm trying to figure out how to combine multiple commands in a
conditional with boolean operators, but I must be missing something.
I thought this is how "or" is meant to be used, but this gives "no"
as the output:
if false; or true
echo yes
else
echo no
end
If this is wrong, what is the proper equivalent of "if false || true"
in bash?
FYI, here is what I'm actually trying to do:
if test $host = 'nfshost'; or echo $distro | grep -Eq 'bsd$'
# do stuff
end
Thanks,
Nick
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users