Fish shell 3.0
111–120 of 227 posts
Re: Fish shell 3.0
#112>? as a glob (wildcard) is deprecated and will be removed in the future ( https://github.com/fish-shell/fish-shell/issues/4520 ) This surprised me, but maybe it's for the best. It got in my way more often than I used it. I'll still miss it.
huh ... interesting. I missed that. I often quote URLs when running wget because of question marks, and I guess I don't have to now.
Re: Fish shell 3.0
#113Fish still doesn't support !! or !command expansion. https://github.com/fish-shell/fish-shell/issues/288
Re: Fish shell 3.0
#114After 15 years, I still struggle to test if a string is empty in shell languages. Do I use square brackets, double square brackets, equal sign, double equal sign, test -n, set -q, wtf mate? Do I need to wrap my string variable in double quotes? single quotes? Fish looks great, and I'm going to give it a try, but I ran into these same old shell scripting issues within 2 minutes of trying to configure my prompt, which…
regexes describe this sort of thing quite concisely and IMO a fair bit more readably than e.g. bash's string replacement syntax, which looks like
"${var#"${var%%[![:space:]]*}"}"
when you want to do the equivalent of s/^\s*(.*?)\s*$/\1/Re: Fish shell 3.0
#115After 15 years, I still struggle to test if a string is empty in shell languages. Do I use square brackets, double square brackets, equal sign, double equal sign, test -n, set -q, wtf mate? Do I need to wrap my string variable in double quotes? single quotes? Fish looks great, and I'm going to give it a try, but I ran into these same old shell scripting issues within 2 minutes of trying to configure my prompt, which…
The trick is that `test` and even `[` (which is essentially another name for `test`) are ordinary commands, that exist as stand-alone binaries as well as identical-behaving built-ins. They masquerade as syntax, but they're really not. You can even call them from other, non-shell languages:
>>> from subprocess import run
>>> run(('/usr/bin/[', '-n', '', ']'))
CompletedProcess(args=('/usr/bin/[', '-n', '', ']'), returncode=1)
>>> run(('/usr/bin/test', '3', '=', '3'))
CompletedProcess(args=('/usr/bin/test', '3', '=', '3'), returncode=0)
That means that they're not allowed to do anything to variables, because the variables are inside the shell. `test` doesn't see `"$git_branch"`, it only sees the content of the variable.Per the normal rules, `"$git_branch"` is an empty string iff $git_branch is empty or unset. Leaving the quotes off can do unexpected things, though a lot less so in fish. Using single quotes means you get a literal string, without any substitution.
You're just looking for an empty string anyway, so you might as well use the equality operator instead of digging through the 18 (!) unary flags prescribed by POSIX. So I'd write either `[ "$git_branch" = "" ]` or `test "$git_branch" = ""`. Some implementations support `==` as another way to write `=`, but `=` is standard.
This modularity makes the shell simpler, but it's not exactly sane. I think that providing `[` was a mistake, because it doesn't look like a command, but maybe having `test` as a command is better than having special expression syntax just for these cases.
Re: Fish shell 3.0
#116Earlier quoted context omitted.
The truly unpredictable UX is when a noob tries to paste a youtube url into their shell and gets a bewildering error message about a wildcard (and the error message carrot doesn't even point at the guilty wildcard!) That is very far from the behavior the user was predicting, unless they've been around the shell block a few times already (in which case they could probably make due in a shittier shell anyway. Is fish o…
>The truly unpredictable UX is when a noob tries to paste Yes, and you've not solved that. You've only solved that one special edge-case where they're pasting "a youtube url". This only pushes the confusing bit further along, and adds some more cruft on top! Quoting is a fact in shells. The way these languages work is through loads of string interpolation, so you kinda need to learn that. And I'd prefer to make the r…
Even when the noob manages to learn that ? is a deprecated but still present wildcard in fish, they'll still be left with the unfortunate reality of being forced to manually quote their urls each and every time, until either fish fixes this or until they switch to zsh (where complaints about url escaping inconsistency don't seem to come up very often at all despite your reasoning.)
Here is an idea to improve the UX that zsh currently offers: use bracketed paste mode and prompt the user whenever they paste something that looks like a URL, asking if they'd like it to be escaped/quoted. y[enter] or n[enter] after the paste is much nicer than remembering to press ' before you paste and then pressing it again after you paste.
Re: Fish shell 3.0
#117Earlier quoted context omitted.
When I’ve been teaching people to program, explaining [0] has been a tragic experience. Starting at [0] is not objectively better than [1]. I actually believe it is objectively worse .
I would like to hear your counterarguments to https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E... , which seems to me like a compelling argument.
Re: Fish shell 3.0
#118After 15 years, I still struggle to test if a string is empty in shell languages. Do I use square brackets, double square brackets, equal sign, double equal sign, test -n, set -q, wtf mate? Do I need to wrap my string variable in double quotes? single quotes? Fish looks great, and I'm going to give it a try, but I ran into these same old shell scripting issues within 2 minutes of trying to configure my prompt, which…
It feels a bit more natural once you've bent your mind enough to understand what the shell is doing. The trick is that `test` and even `[` (which is essentially another name for `test`) are ordinary commands, that exist as stand-alone binaries as well as identical-behaving built-ins. They masquerade as syntax, but they're really not. You can even call them from other, non-shell languages: >>> from subprocess import r…
For instance, one way to use it is
test somestring
to test if "somestring" is empty. POSIX mandates that test with exactly one argument succeeds iff that argument is a non-empty string, to allow that. Fish's test is POSIX-conformant.Now, that means that
test -n
is true! Which is also triggered for test -n $var
if $var has 0 elements.This is a problem and should be improved.
Re: Fish shell 3.0
#119Still no auto-escaping or quoting for pasted URLs, that's really disappointing. I respect fish's stated goals of user friedlieness, but I just don't think they've realized that goal in ways that other more mainstream shells have: > mpv https://www.youtube.com/watch?v=LBoF1e5YDdQ fish: No matches for wildcard 'https://www.youtube.com/watch?v=LBoF1e5YDdQ'. See `help expand`. mpv https://www.youtube.com/watch?v=LBoF1e5Y…
The way we plan to address this in fish is to make ? an ordinary character instead of a wildcard. Then URLs will have nothing to escape.
You can opt into this change today by setting the 'qmark-noglob' feature flag:
set -U fish_features qmark-noglob
now ? no longer globs.Re: Fish shell 3.0
#120Apart 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