|
|
Subscribe / Log in / New account

New features in the fish shell

New features in the fish shell

Posted Sep 29, 2020 18:18 UTC (Tue) by ibukanov (subscriber, #3942)
Parent article: New features in the fish shell

I am surprised that it took so long for fish with its focus on UI experience to implement || and && as shortcuts for longer ;or/and variants. These are not esoteric operations that are useful only for advanced scripting. I use them in bash in interactive session often. For example, git push && cd .. && git push when working with submodules or various make && run-resulting-executable.


to post comments

New features in the fish shell

Posted Sep 30, 2020 17:54 UTC (Wed) by glasserc (subscriber, #108472) [Link] (3 responses)

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.

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 © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds