Skip to content

Commit

Permalink
fix(_comp_compgen_usergroup): avoid directly overwriting COMPREPLY
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 1, 2023
1 parent 1e4315a commit d380498
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -2017,16 +2017,19 @@ _comp_compgen_usergroup()
# Completing group after 'user\:gr<TAB>'.
# Reply with a list of groups prefixed with 'user:', readline will
# escape to the colon.
local _prefix
_prefix=${cur%%*([^:])}
_prefix=${_prefix//\\/}
local tmp
if [[ ${1-} == -u ]]; then
_comp_compgen -c "${cur#*:}" allowed_groups
_comp_compgen -v tmp -c "${cur#*:}" allowed_groups
else
_comp_compgen -c "${cur#*:}" -- -g
_comp_compgen -v tmp -c "${cur#*:}" -- -g
fi
if ((${#tmp[@]})); then
local _prefix=${cur%%*([^:])}
_prefix=${_prefix//\\/}
local -a _tmp=("${tmp[@]/#/$_prefix}")
_comp_unlocal tmp
_comp_compgen_set "${_tmp[@]}"
fi
((${#COMPREPLY[@]})) &&
COMPREPLY=("${COMPREPLY[@]/#/$_prefix}")
elif [[ $cur == *:* ]]; then
# Completing group after 'user:gr<TAB>'.
# Reply with a list of unprefixed groups since readline with split on :
Expand Down

0 comments on commit d380498

Please sign in to comment.