|
|
Subscribe / Log in / New account

New features in the fish shell

New features in the fish shell

Posted Sep 30, 2020 23:19 UTC (Wed) by johannes (guest, #116140)
In reply to: New features in the fish shell by glasserc
Parent article: New features in the fish shell

> also, complicated boolean conditions in if statements in fish are a little clumsy because only the first command (until the first semicolon) is the condition, so && helps mitigate that.

Surprisingly, a condition for if/while consists of a command plus a tail of and/or commands, see https://github.com/fish-shell/fish-shell/blob/master/src/....
This means you can write chained conditions like this:

if cheap-condition; or expensive-condition-part-1; and expensive-condition-part-2
# body goes here
end

Although as a developer I agree that && and || look better.
Using begin/end for grouping allows for more complex conditions.


to post comments

New features in the fish shell

Posted Oct 1, 2020 12:36 UTC (Thu) by widowmaker (guest, #142307) [Link]

As developer, I disagree that && and || have better readability. Usually, too much special characters only make it worse.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds