From ea46f81b3e8da3cb9bff4da42db46b934c57148f Mon Sep 17 00:00:00 2001 From: Andrii Sultanov Date: Tue, 10 Dec 2024 09:21:09 +0000 Subject: [PATCH] xe-cli completion: Hide COMPREPLY manipulation behind functions Though the majority of completions were already using set_completions and the like to add completion suggestions, there were two leftovers still needlessly changing COMPREPLY themselves. This caused bugs, as in the case of xe vm-import filename= autocompleting all of the filenames into the prompt instead of presenting the choice. Let only these functions operate on COMPREPLY directly. Signed-off-by: Andrii Sultanov --- ocaml/xe-cli/bash-completion | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ocaml/xe-cli/bash-completion b/ocaml/xe-cli/bash-completion index 84fd3656a6..aae832f4d6 100644 --- a/ocaml/xe-cli/bash-completion +++ b/ocaml/xe-cli/bash-completion @@ -143,9 +143,9 @@ _xe() IFS=$'\n,' # Here we actually WANT file name completion, so using compgen is OK. local comp_files=$(compgen -f "$value") - COMPREPLY=( "$comp_files" ) __xe_debug "triggering filename completion for the value:" __xe_debug $(__tab_delimited_newline_array "$comp_files") + set_completions "$comp_files" "$value" return 0 ;; @@ -156,7 +156,6 @@ _xe() if [ "${OLDSTYLE_WORDS[1]}" == "pif-reconfigure-ip" ]; then IFS=$'\n,' suggested_modes="dhcp,static,none" - COMPREPLY=( $(compgen -W "dhcp ,static ,none" -- "$value") ) elif [ "${COMP_WORDS[1]}" == "pif-reconfigure-ipv6" ]; then IFS=$'\n,' suggested_modes="dhcp,static,none,autoconf"