Fix abbr return status

This was supposed to act like `type -q` or `command -q`, in that it
returns 0 if at least 1 exists.

But because it used the wrong variable it didn't.

Fixes #8431.
This commit is contained in:
Fabian Homborg 2021-11-11 16:46:23 +01:00
parent aa470e12b2
commit c16e30931b
2 changed files with 13 additions and 1 deletions

View File

@ -59,7 +59,7 @@ function abbr --description "Manage abbreviations"
# We return 0 if any arg exists, whereas `set -q` returns the number of undefined arguments.
# But we should be consistent with `type -q` and `command -q`.
for var in $escaped
set -q $escaped; and return 0
set -q $var; and return 0
end
return 1
else

View File

@ -94,3 +94,15 @@ abbr --add --global __abbr14 bbbbbbbbbbbbb
abbr --erase __abbr13 __abbr14
abbr | grep __abbr13
abbr | grep __abbr14
abbr -q banana
echo $status
# CHECK: 1
abbr -q __abbr8 banana
echo $status
# CHECK: 0
abbr -q banana __abbr8 foobar
echo $status
# CHECK: 0