6 ms·
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
by robin_reala 8y ago
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
- binaryanomaly 8y agoOh yes
- hak8or 8y agoThis is absolutely thrilling! I often have to flip between bash and fish due to some archaic tools we wrote relying on bash in wierd ways, and the swap between how both handled logic like this was cumbersome. Glad to see one less potential reason my team won't use fish.
- aequitas 8y agoThough I've really grown toward the 'everything as a function' pattern that Fish is trying to do, this is definitely a step back in the right direction. I might even wish for `$()` to be supported as well to allow even better copy pastable oneliners from Bash.
- OJFord 8y agoI thought it was to be included in 3.0, there's certainly an issue on it.
- e12e 8y agoYour quoting is a bit confusing, as "`cmd...`" and "$(cmd...)" are similar,, while backtick-dollar-paranthesis is just asking for trouble... ;) I take it fish didn't / doesn't support either?
- sitharus 8y agoFish uses parentheses for command expansion, so backticks aren’t supported and the dollar sign is only for variable substitution.
- ElijahLynn 8y agoFish just uses (cmd), no $.
- e12e 8y agoAh, which I guess is why no subshell support?
- cormacrelf 8y agoThere 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 https://github.com/fish-shell/fish-shell/issues/1439
- aequitas 8y agoSorry for the confusion, I'm to used to `` as code style for markdown, forgot HN doesn't support it. I'm glad Fish doesn't support the backtick syntax :). Like others mention it just drops the dollar from a 'regular' parenthesis expansion.
- giancarlostoro 8y agoAwesome! I remember bumping into the github issue over it but I guess I didn't read far enough (or maybe it was long ago) to see that they were finally going to support && and || instead.
- maxfurman 8y agoFinally! 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.
- Buttons840 8y agoJust because a language knows what you mean to do and can give a specific error messagr doesn't mean that, in general, and specifically, the developers want to commit to supporting && as valid syntax forever. Perhaps the language creators have plans for future syntax that would not allow what you want. Even if for now the language evidently knows what you mean from the error message. In this specific case, the developers of fish apparently decided && was good to add.
- zorked 8y agoThat 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.
- robdachshund 8y agoIf print() is a function why should you be able to call it like that? Python 3 was just fixing that inconsistency. Functions have their arguments inside of parentheses. Should we be able to call "requests.post url, data"? It sounds like you are upset with the language for resolving something that never made sense to begin with.
- pseudalopex 8y agoWhat does someone want if they write "bar = print foo,"? Is it the same if "print" isn't the built-in function?
- shaki-dora 8y agoOperator 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 better way to do function calls, and it is ruby.
- phirschybar 8y agoawesome! can't tell you the number of times I have slammed into this when copy/pasting.
- hinkley 8y agoThat’s new? Suddenly I feel less guilty about dodging coworkers who have been trying for years to get other people to try fish. But maybe now it’s getting closer to production readiness.
- faho 8y agoFish uses (and still supports) `command1; and command2` instead of `command1 && command2` (and similarly for `||`/`or` and `!`/`not`). The syntax is different, the semantics are the same.
- StavrosK 8y agoThe fact that it doesn't support your particular preferred syntax doesn't mean it's not production-ready.
- jhardy54 8y ago> your particular preferred syntax I think it's called POSIX.
- pstadler 8y agoI‘m not switching to fish because of its lack of POSIX compliancy. This is a valid complaint.
- faho 8y agoIt is! But calling it "getting closer to production readiness" feels a tad insulting. It's probably just a bit of snark, so it's not worth getting up in arms about, but it's not really friendly phrasing.
- eberkund 8y agoI upgraded with homebrew to v3.0 but the && syntax still doesn't work, do I have to do something special to enable it?
- robin_reala 8y agoClose your shell and open it (or run fish again). You’re probably still in the original fish 2.7 that had previously launched. fish --version should show 3.0.0 (edit: yeah, that’s not going to work).
- therealdrag0 8y ago`fish --version` showed 3.0.0, after brew update but without closing terminal, but `ls && echo finally` still didn't work. However, closing and re-opening terminal, it now works.
- faho 8y ago`fish --version` starts a new fish that prints _its_ version. You were still running the old version, and `echo $version` would have told you.
- robin_reala 8y agoHah, oops, should have realised that.
- cies 8y agoBecause you still run the old version as your shell, from which you run the new version merely to have it print its version.
- lachlantula 8y agolooks like i'm switching back to it again from zsh