aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/abbr.fish
diff options
context:
space:
mode:
authorGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2015-03-13 16:32:05 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2015-03-13 16:32:05 +0800
commit48d353610fc5fac5a9d491e9d0ad9c7e4c79fe7e (patch)
tree843aaa5308de743505143a4114f64f7f94c4fbd7 /share/functions/abbr.fish
parentbff68f3bfc25feb50be3d870c6a535a7561ecc10 (diff)
abbr: coalesce multiple arguments to --add
Makes the behaviour of the script match the documentation.
Diffstat (limited to 'share/functions/abbr.fish')
-rw-r--r--share/functions/abbr.fish12
1 files changed, 8 insertions, 4 deletions
diff --git a/share/functions/abbr.fish b/share/functions/abbr.fish
index ce104f12..7669b8fd 100644
--- a/share/functions/abbr.fish
+++ b/share/functions/abbr.fish
@@ -10,9 +10,13 @@ function abbr --description "Manage abbreviations"
set -l mode_arg
set -l needs_arg no
while set -q argv[1]
- if test $needs_arg = yes
+ if test $needs_arg = single
set mode_arg $argv[1]
set needs_arg no
+ else if test $needs_arg = coalesce
+ set mode_arg "$argv"
+ set needs_arg no
+ set -e argv
else
set -l new_mode
switch $argv[1]
@@ -21,10 +25,10 @@ function abbr --description "Manage abbreviations"
return 0
case '-a' '--add'
set new_mode add
- set needs_arg yes
+ set needs_arg coalesce
case '-r' '--remove'
set new_mode remove
- set needs_arg yes
+ set needs_arg single
case '-l' '--list'
set new_mode list
case '-s' '--show'
@@ -48,7 +52,7 @@ function abbr --description "Manage abbreviations"
end
set -e argv[1]
end
- if test $needs_arg = yes
+ if test $needs_arg != no
printf ( _ "%s: option requires an argument -- %s\n" ) abbr $mode_flag >&2
return 1
end