From eeec845b39350a997b93eadb58b178d6304b224d Mon Sep 17 00:00:00 2001 From: Andrii Sultanov Date: Thu, 28 Nov 2024 12:48:01 +0000 Subject: [PATCH 1/2] xe-cli completion: Use grep -E instead of egrep Otherwise newer packages in XS9 issue "egrep: warning: egrep is obsolescent; using grep -E" warnings all over the place. Signed-off-by: Andrii Sultanov --- ocaml/xe-cli/bash-completion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/xe-cli/bash-completion b/ocaml/xe-cli/bash-completion index b4ba612713..84fd3656a6 100644 --- a/ocaml/xe-cli/bash-completion +++ b/ocaml/xe-cli/bash-completion @@ -675,7 +675,7 @@ description() __process_params() { - echo "$1" | cut -d: -f2- | egrep -v "^ $" | cut -c 2- | \ + echo "$1" | cut -d: -f2- | grep -Ev "^ $" | cut -c 2- | \ sed -e 's/,/=,/g' -e 's/$/=/g' -e 's/:=/:/g' -e 's/-=/-/g' -e 's/ //g' } From ea46f81b3e8da3cb9bff4da42db46b934c57148f Mon Sep 17 00:00:00 2001 From: Andrii Sultanov Date: Tue, 10 Dec 2024 09:21:09 +0000 Subject: [PATCH 2/2] 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"