You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-q or --query test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined, or 255 if more than 255 variables are not defined.
while abbr --query works contradicationary:
-q or --query Return 0 (true) if one of the WORDs is an abbreviation.
Why set --query can't behave more like abbr (check whether at least one variable is defined and return 0 in this case)? It is a breaking change of course and is not a problem when only one thing checked with set/abbr.
We should just make abbr behave like set. Either behavior is fine by itself and it's always possible to get the other by doing multiple queries, so we should change the less used tool to match the more used one.
--query is generally a complete mess 😄 In all of these commands, only the first argument is true, the rest are false. But they produce a bunch of different outputs.
function foo
set-l var1
set--query var1 var2 var3
echo$status# 2functions--query foo bar baz
echo$status# 2type--query foo bar baz
echo$status# 0builtin--querytrue foo bar
echo$status# 0command--queryls notCommand1 notCommand2
echo$status# 0
abbr abbr1 blah
abbr --query abbr1 abbr2 abbr3
echo$status# 1end
Activity
faho commentedon Nov 11, 2021
We should just make abbr behave like set. Either behavior is fine by itself and it's always possible to get the other by doing multiple queries, so we should change the less used tool to match the more used one.
floam commentedon Nov 11, 2021
Nice job, you noticed a design flaw! Yeah, let's adjust abbr to do the same thing as set.
faho commentedon Nov 11, 2021
Okay,
abbrreturns 0 only if all given words exist. It doesn't do the counting thatsetdoes.floam commentedon Nov 11, 2021
So it doesn't even match the docs?
floam commentedon Nov 11, 2021
I call that a free pass to make it do whatever, @faho. Want to change it up?
IlanCosman commentedon Nov 11, 2021
--queryis generally a complete mess 😄 In all of these commands, only the first argument is true, the rest are false. But they produce a bunch of different outputs.faho commentedon Nov 11, 2021
Ah, okay, there's a bug:
fish-shell/share/functions/abbr.fish
Lines 55 to 64 in aa470e1
That
set -q $escapedshould be aset -q $var.The comment says it's doing this style of returning to match
typeandcommand.faho commentedon Nov 11, 2021
Okay, I made abbr do what the documentation says, and what the comments explain is to be consistent with type and command.
That's the easier change than making it consistent with
set.[-]Inconsistency with set and abbr[/-][+]Abbr -q return status inconsistent[/+]CHANGELOG updates for 3.4.0