Skip to content

Commit f2e7399

Browse files
committed
completion: handle short opts without spaces
Apparently some people want to use clush -wfoo...
1 parent c05fdf4 commit f2e7399

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bash_completion.d/clush

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ _clush()
3232
local cur prev words cword split
3333
local i word options="" compopts="" skip=argv0 groupsource="" cleangroup=""
3434
local mode=command target_set=""
35+
local shortopt=""
3536

3637
_init_completion -s -n : || return
3738

@@ -76,6 +77,15 @@ _clush()
7677
esac
7778
done
7879

80+
# split short opts without space...
81+
case "$cur" in
82+
-[a-z]*)
83+
shortopt="${cur:0:2}"
84+
prev="$shortopt"
85+
cur="${cur:2}"
86+
;;
87+
esac
88+
7989
case "$prev" in
8090
-w|-x|-g|--group|-X)
8191
case "$cur" in
@@ -134,7 +144,9 @@ _clush()
134144
fi
135145

136146
# append space for everything that doesn't end in `:` (likely a groupsource)
137-
mapfile -t COMPREPLY < <(compgen -W "$options" -- "$cur" | sed -e 's/[^:]$/& /')
147+
mapfile -t COMPREPLY \
148+
< <(compgen -W "$options" -- "$cur" \
149+
| sed -e 's/[^:]$/& /' -e "s/^/$shortopt/")
138150
# remove the prefix from COMPREPLY if $cur contains colons and
139151
# COMP_WORDBREAKS splits on colons...
140152
__ltrim_colon_completions "$cur"

0 commit comments

Comments
 (0)