On Sat, 7 Dec 2013, Nick Mapsy 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?

You have to use blocks:

if begin; false; or true; end
  echo yes
else
  echo no
end

There is some discussion on GitHub, starting from 
https://github.com/fish-shell/fish-shell/issues/150#issuecomment-16717275 
of how this syntax might be improved.

> FYI, here is what I'm actually trying to do:
> if test $host = 'nfshost'; or echo $distro | grep -Eq 'bsd$'
>   # do stuff
> end

Try
if  begin
      test $host = 'nfshost'
      or echo $distro | grep -Eq 'bsd$'
    end
  # do stuff
end

David Adam
zanc...@ucc.gu.uwa.edu.au

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to