Live data from Hacker News

Fish shell 3.0

github.com

181–190 of 227 posts

Re: Fish shell 3.0

#181
How do people manage scripts to be used in such niche shells? I started using zsh at work recently, while I quite enjoy the shell experience it is a pain to rewrite all bash scripts to zsh or add lines of codes for compatibility. Any pointers?

Re: Fish shell 3.0

#182

Can anyone who's experienced with both fish and zsh comment on reasons fish might be better?

fish doesn't try to support all of the weird historical quirks of Bourne-style shells, so its grammar and built-in 'API' are far simpler and clearer. Its out-of-the-box configuration is much much nicer for most people than zsh's. Completion definitions are easier to read/write. Its source code seems less byzantine. And its GitHub-based development model is more accessible. The down side is that it's functionally very…

Job control should be fully featured - backgrounding, stopping/continuing, and disowning are all implemented. If there's something missing we'd definitely look at adding it.

Re: Fish shell 3.0

#183

Earlier quoted context omitted.

You just make ranges end-inclusive, and then it's x[1:10] + x[11:len(x)]. The best of both worlds is when a language provides both end-exclusive and end-inclusive slice syntax, as in e.g. Nim: x[0..<10] is end-exclusive, and it's very clear that it is.

But then you no longer get back 10-1 elements, you get back 10-1+1.

So what? You're going to have off-by-one errors no matter what convention you adopt. Python glosses over it by providing the alternative syntax x[-1] for what you would otherwise have to write as x[len(x)-1]. But it's at least as valid to provide alternative syntax for inclusive ranges. And logically, if the first element of x is x[0], the last element should be x[-0], not x[-1].

Half-open intervals are appropriate when you're thinking of them as subspaces of a continuum. When you're thinking of them as subsequences of discrete elements, closed intervals are usually more natural.

Ruby is the only language I know that really seems to have tried to address the problem, providing different syntax for every way you might want to take a subsequence from an array:

    x[5..8]  # elements [5] through [8], including [8]
    x[5...9] # elements [5] through [9], excluding [9]
    x[5, 4]  # four elements, starting at [5]
If you were working in pure, pencil-and-paper mathematics, you'd choose whether to index a particular sequence from 0 or 1 based on what made your formula look nicer. Both are common. But that's not an approach I'd suggest for a programming language.

Re: Fish shell 3.0

#184

Earlier quoted context omitted.

What does someone want if they write "bar = print foo,"? Is it the same if "print" isn't the built-in function?

Operator precedence isn't really a new concept, and Python relies on it in plenty other situations: bar = 1 + 1 I do believe Python made the right call, actually: print needed to be unified with functions, and dropping the requirement for parenthesis for function calls would have introduced so much incompatibility as to make the Python 2 -> 3 transition far more difficult. But ignoring the legacy issue, there is a be…

Didn't Ruby borrow it from Perl?

Re: Fish shell 3.0

#185

Earlier quoted context omitted.

fish doesn't try to support all of the weird historical quirks of Bourne-style shells, so its grammar and built-in 'API' are far simpler and clearer. Its out-of-the-box configuration is much much nicer for most people than zsh's. Completion definitions are easier to read/write. Its source code seems less byzantine. And its GitHub-based development model is more accessible. The down side is that it's functionally very…

Job control should be fully featured - backgrounding, stopping/continuing, and disowning are all implemented. If there's something missing we'd definitely look at adding it.

Yeah, you're right of course. I think i was conflating job control with sub-shells, sorry.

Re: Fish shell 3.0

#186
post #44

Earlier quoted context omitted.

Finally! Fish 2.x shows you a message along the lines of "use `and` instead of `&&`", which is infuriating - it clearly knows what I want to do, and refuses to do it. I love fish and use it as my default shell, but I'm glad to see the fish team take a few steps towards bash compat.

That reminds me of the very specific nag messages I get from Python 3 when I don't write parens around parameters for print... do what I want already.

In Python 3 there was an explicit decision not to support print as a statement, and rather as a function call.

Re: Fish shell 3.0

#187
post #181

How do people manage scripts to be used in such niche shells? I started using zsh at work recently, while I quite enjoy the shell experience it is a pain to rewrite all bash scripts to zsh or add lines of codes for compatibility. Any pointers?

You don’t. ;-) Use fish/zsh interactively, sh for simple scripts, Python for the more complex.

Re: Fish shell 3.0

#188
post #98

Earlier quoted context omitted.

Fish just uses (cmd), no $.

Ah, which I guess is why no subshell support?

There are other ways to do subshells than using the same syntax, just that the Fish developers never did it, maybe because it's not requested enough. I think it's still the most annoying thing about Fish, and the most convincing reason to switch away again. I frequently drop into bash to do

    (cd subdirectory && command --that might.fail) && run --command-in-original-dir --only-if-subshell-succeeded
... and expect to still be in the original dir when it's done. Any solution in Fish using "&& cd -" at the end of a block AFTER a maybe-failing command is just wrong, and there seriously isn't any way except saving and restoring $PWD every time you want subshell functionality, or using "; cd -" and manually saving the $status, which is equally as frustrating.

There are some non-syntactic suggestions in https://github.com/fish-shell/fish-shell/issues/1439

Re: Fish shell 3.0

#189

Apart from the other good stuff in this release, I think this will make a lot of things much easier: fish now supports && (like and), || (like or), and ! (like not), for better migration from POSIX-compliant shells

looks like i'm switching back to it again from zsh

Re: Fish shell 3.0

#190
post #181

How do people manage scripts to be used in such niche shells? I started using zsh at work recently, while I quite enjoy the shell experience it is a pain to rewrite all bash scripts to zsh or add lines of codes for compatibility. Any pointers?

You don’t. ;-) Use fish/zsh interactively, sh for simple scripts, Python for the more complex.

Yeah I get that. But this method doesn't help for scripts that need to modify the current session state (such as export session variables). I am guessing here that such scripts are an edge case and most shell scripts can be simply executed with sh.
Post reply on HN