From 468c6ff0f827ed2d5010b310a2d18918b14349f0 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 4 Oct 2020 12:31:33 +0200 Subject: [PATCH] abbr: Erase all abbrs in one go Simplifies returns, also allows erroring out without erasing anything if an abbr name was bogus --- share/functions/abbr.fish | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/share/functions/abbr.fish b/share/functions/abbr.fish index 7caf25526..ae8dd794e 100644 --- a/share/functions/abbr.fish +++ b/share/functions/abbr.fish @@ -97,6 +97,7 @@ end function __fish_abbr_erase --no-scope-shadowing set -l ret 0 + set -l abbr_var_names for abbr_name in $argv # Because of the way abbreviations are expanded there can't be any spaces in the key. set -l escaped_name (string escape -- $abbr_name) @@ -108,13 +109,11 @@ function __fish_abbr_erase --no-scope-shadowing set -l abbr_var_name _fish_abbr_(string escape --style=var -- $abbr_name) - if not set -q $abbr_var_name - set ret 4 # like `set -e doesnt_exist` - end - - set -e $abbr_var_name + set -a abbr_var_names $abbr_var_name end - return $ret + # And then erase them all in one go. + # Our return value is that of `set -e`. + set -e $abbr_var_names end function __fish_abbr_rename --no-scope-shadowing