From 9ac0f55513b5fc544a6dfd1e5cd1b206f452eb1b Mon Sep 17 00:00:00 2001 From: Jeffrey Faer Date: Wed, 1 May 2024 12:54:23 -0600 Subject: [PATCH] Don't quote different completion types. They're not going through compgen so they don't need it. --- bash_completionsV2.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/bash_completionsV2.go b/bash_completionsV2.go index 98c56968..79846bb4 100644 --- a/bash_completionsV2.go +++ b/bash_completionsV2.go @@ -220,24 +220,15 @@ __%[1]s_handle_completion_types() { # completions at once on the command-line we must remove the descriptions. # https://github.com/spf13/cobra/issues/1508 local tab=$'\t' comp - local matches=() for comp in "${completions[@]}"; do [[ -z $comp ]] && continue # Strip any description comp=${comp%%%%$tab*} # Only consider the completions that match if [[ $comp == "$cur"* ]]; then - # Strictly speaking we could append directly to COMPREPLY here. - # 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" ) + COMPREPLY+=( "$comp" ) fi done - while IFS='' read -r comp; do - COMPREPLY+=( "$comp" ) - done < <(printf "%%q\n" "${matches[@]}") ;; *)