mirror of https://github.com/spf13/cobra.git
Don't quote different completion types.
They're not going through compgen so they don't need it. Signed-off-by: Jeffrey Faer <jeffrey.faer@gmail.com>
This commit is contained in:
parent
497d36cfc1
commit
76d900bc72
|
@ -220,24 +220,15 @@ __%[1]s_handle_completion_types() {
|
||||||
# completions at once on the command-line we must remove the descriptions.
|
# completions at once on the command-line we must remove the descriptions.
|
||||||
# https://github.com/spf13/cobra/issues/1508
|
# https://github.com/spf13/cobra/issues/1508
|
||||||
local tab=$'\t' comp
|
local tab=$'\t' comp
|
||||||
local matches=()
|
|
||||||
for comp in "${completions[@]}"; do
|
for comp in "${completions[@]}"; do
|
||||||
[[ -z $comp ]] && continue
|
[[ -z $comp ]] && continue
|
||||||
# Strip any description
|
# Strip any description
|
||||||
comp=${comp%%%%$tab*}
|
comp=${comp%%%%$tab*}
|
||||||
# Only consider the completions that match
|
# Only consider the completions that match
|
||||||
if [[ $comp == "$cur"* ]]; then
|
if [[ $comp == "$cur"* ]]; then
|
||||||
# Strictly speaking we could append directly to COMPREPLY here.
|
COMPREPLY+=( "$comp" )
|
||||||
# But there's a pretty big performance hit involved with
|
|
||||||
# creating one subshell to printf %%q for each completion that
|
|
||||||
# matches. Instead, batch all the matches up so we can quote
|
|
||||||
# them all at once in a single printf call.
|
|
||||||
matches+=( "$comp" )
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
while IFS='' read -r comp; do
|
|
||||||
COMPREPLY+=( "$comp" )
|
|
||||||
done < <(printf "%%q\n" "${matches[@]}")
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
|
Loading…
Reference in New Issue