|
|
Log in / Subscribe / Register

New features in the fish shell

New features in the fish shell

Posted Sep 30, 2020 17:54 UTC (Wed) by glasserc (subscriber, #108472)
In reply to: New features in the fish shell by ibukanov
Parent article: New features in the fish shell

I'm a long-time fish user who feels the opposite way. I really like the regular syntax of the fish shell language (no [[, then, fi, esac) and introducing special syntax for and and or detracts from that. The linked discussion on Github also has additional arguments in both directions -- for example, && and & function very differently despite their apparent visual similarity; but 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.


to post comments

New features in the fish shell

Posted Sep 30, 2020 23:19 UTC (Wed) by johannes (guest, #116140) [Link] (1 responses)

> 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.

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.

New features in the fish shell

Posted Oct 2, 2020 23:21 UTC (Fri) by qlyoung (guest, #142338) [Link]

Allowing && and || massively increases compatibility with copy-pasting shell snippets on the internet into your shell, for those who live life on the edge.


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