Skip to content

Commit

Permalink
xe-cli completion: Hide COMPREPLY manipulation behind functions
Browse files Browse the repository at this point in the history
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=<TAB>

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 <[email protected]>
  • Loading branch information
last-genius committed Dec 10, 2024
1 parent eeec845 commit ea46f81
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions ocaml/xe-cli/bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -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
;;

Expand All @@ -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"
Expand Down

0 comments on commit ea46f81

Please sign in to comment.