On 11/11/2014 11:45 PM, Marcin Zajączkowski wrote: > Hello again, > > Another question related to fish scripting. How can I set a value to a > variable to be able to use it in `if`? > > if test $myBool > ... > end
This should work (at least in my slightly outdated version of fish)! What it tests is if $mybool is empty: > if test $myBool; echo yes; else; echo no; end no > set myBool 0 > if test $myBool; echo yes; else; echo no; end yes Interestingly, > set myBool ' ' # i.e., a space > if test $myBool; echo yes; else; echo no; end yes A trick that I sometimes use in “other shells” is $ myBool=true $ if $myBool; then echo yes; else echo no; fi yes $ myBool=false $ if $myBool; then echo yes; else echo no; fi no In this case, note that $ unset myBool $ if $myBool; then echo yes; else echo no; fi yes This does not work in fish because variables cannot be used as commands. You would have to use ‘alias’ / ‘function’. Elias ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk _______________________________________________ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users