Skip to content

Commit 2c9c9e7

Browse files
authored
xe-cli completion bugfixes (#6166)
**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 --- **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=<TAB>` autocompleting all of the filenames into the prompt instead of presenting the choice. Let only these functions operate on COMPREPLY directly.
2 parents f14fcdf + ea46f81 commit 2c9c9e7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ocaml/xe-cli/bash-completion

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ _xe()
143143
IFS=$'\n,'
144144
# Here we actually WANT file name completion, so using compgen is OK.
145145
local comp_files=$(compgen -f "$value")
146-
COMPREPLY=( "$comp_files" )
147146
__xe_debug "triggering filename completion for the value:"
148147
__xe_debug $(__tab_delimited_newline_array "$comp_files")
148+
set_completions "$comp_files" "$value"
149149
return 0
150150
;;
151151

@@ -156,7 +156,6 @@ _xe()
156156
if [ "${OLDSTYLE_WORDS[1]}" == "pif-reconfigure-ip" ]; then
157157
IFS=$'\n,'
158158
suggested_modes="dhcp,static,none"
159-
COMPREPLY=( $(compgen -W "dhcp ,static ,none" -- "$value") )
160159
elif [ "${COMP_WORDS[1]}" == "pif-reconfigure-ipv6" ]; then
161160
IFS=$'\n,'
162161
suggested_modes="dhcp,static,none,autoconf"
@@ -675,7 +674,7 @@ description()
675674

676675
__process_params()
677676
{
678-
echo "$1" | cut -d: -f2- | egrep -v "^ $" | cut -c 2- | \
677+
echo "$1" | cut -d: -f2- | grep -Ev "^ $" | cut -c 2- | \
679678
sed -e 's/,/=,/g' -e 's/$/=/g' -e 's/:=/:/g' -e 's/-=/-/g' -e 's/ //g'
680679
}
681680

0 commit comments

Comments
 (0)