Skip to content

Commit d380498

Browse files
committed
fix(_comp_compgen_usergroup): avoid directly overwriting COMPREPLY
1 parent 1e4315a commit d380498

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

bash_completion

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,16 +2017,19 @@ _comp_compgen_usergroup()
20172017
# Completing group after 'user\:gr<TAB>'.
20182018
# Reply with a list of groups prefixed with 'user:', readline will
20192019
# escape to the colon.
2020-
local _prefix
2021-
_prefix=${cur%%*([^:])}
2022-
_prefix=${_prefix//\\/}
2020+
local tmp
20232021
if [[ ${1-} == -u ]]; then
2024-
_comp_compgen -c "${cur#*:}" allowed_groups
2022+
_comp_compgen -v tmp -c "${cur#*:}" allowed_groups
20252023
else
2026-
_comp_compgen -c "${cur#*:}" -- -g
2024+
_comp_compgen -v tmp -c "${cur#*:}" -- -g
2025+
fi
2026+
if ((${#tmp[@]})); then
2027+
local _prefix=${cur%%*([^:])}
2028+
_prefix=${_prefix//\\/}
2029+
local -a _tmp=("${tmp[@]/#/$_prefix}")
2030+
_comp_unlocal tmp
2031+
_comp_compgen_set "${_tmp[@]}"
20272032
fi
2028-
((${#COMPREPLY[@]})) &&
2029-
COMPREPLY=("${COMPREPLY[@]/#/$_prefix}")
20302033
elif [[ $cur == *:* ]]; then
20312034
# Completing group after 'user:gr<TAB>'.
20322035
# Reply with a list of unprefixed groups since readline with split on :

0 commit comments

Comments
 (0)