aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions
diff options
context:
space:
mode:
authorGravatar Fabian Homborg <FHomborg@gmail.com>2016-05-19 17:54:15 +0200
committerGravatar Fabian Homborg <FHomborg@gmail.com>2016-05-23 19:59:02 +0200
commitdac8483f7e96ac9d18152c571ba7ed48f2341f4d (patch)
treeaf87eca68629f4f5ca03cda6276d66f8eb4891b5 /share/functions
parent46f4819ffade061d202973996e4974562a45ecd0 (diff)
Simplify some code in abbr
We actually need less duplication here.
Diffstat (limited to 'share/functions')
-rw-r--r--share/functions/abbr.fish23
1 files changed, 11 insertions, 12 deletions
diff --git a/share/functions/abbr.fish b/share/functions/abbr.fish
index beaeda30..cdb528ae 100644
--- a/share/functions/abbr.fish
+++ b/share/functions/abbr.fish
@@ -39,6 +39,17 @@ function abbr --description "Manage abbreviations"
set -e argv[1]
end
+ # If run with no options, treat it like --add if we have an argument, or
+ # --show if we do not have an argument
+ if not set -q mode[1]
+ if set -q argv[1]
+ set mode add
+ set needs_arg multi
+ else
+ set mode show
+ end
+ end
+
if test $needs_arg = single
set mode_arg $argv[1]
set needs_arg no
@@ -53,18 +64,6 @@ function abbr --description "Manage abbreviations"
return 1
end
- # If run with no options, treat it like --add if we have an argument, or
- # --show if we do not have an argument
- if test -z "$mode"
- if set -q argv[1]
- set mode 'add'
- set mode_arg $argv
- set -e argv
- else
- set mode 'show'
- end
- end
-
# none of our modes want any excess arguments
if set -q argv[1]
printf ( _ "%s: Unexpected argument -- %s\n" ) abbr $argv[1] >&2