On Tue, 2019-05-07 at 11:48 -0500, Jonathon Jongsma wrote: > minor proposed changes > --- > Although I'm not an expert in either shell scripting or bash- > completion, it seems to me that this > small change accomplishes the same thing, but seems slightly cleaner? > Can you see any behavior > difference with my fixup applied? > > bash-completion/virt-viewer | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) > > diff --git a/bash-completion/virt-viewer b/bash-completion/virt- > viewer > index 40f6e95..fefb82a 100644 > --- a/bash-completion/virt-viewer > +++ b/bash-completion/virt-viewer > @@ -13,25 +13,22 @@ _virt_viewer_complete() > # arguments, e.g. connection URI (with the default set it's > # split into multiple items within the array). Fortunately, > # there's a fixup function for the array. > - _get_comp_words_by_ref -n "\"'><=;|&(:" -w words -i cword > - COMP_WORDS=( "${words[@]}" ) > - COMP_CWORD=${cword} > - cur=${COMP_WORDS[$COMP_CWORD]} > + _get_comp_words_by_ref -n "\"'><=;|&(:" -w words -i cword -c cur > > MODE="--name" > ALL="--all" > # See what URI is user trying to connect to. Honour that. > - for ((c=1; c<=${COMP_CWORD}; c++)); do > - case "${COMP_WORDS[c]}" in > + for ((c=1; c<=${cword}; c++)); do > + case "${words[c]}" in > -c|--connect) > - if [[ -n "${COMP_WORDS[c+1]}" ]]; then > - URI="${COMP_WORDS[c+1]}" > + if [[ -n "${words[c+1]}" ]]; then > + URI="${words[c+1]}" > c=$((++c)) > fi > ;; > > --connect=*) > - w=${COMP_WORDS[c]#*=} > + w=${words[c]#*=} > if [[ -z "$w" ]] ; then > return > fi Actually, now that I look at the /usr/share/bash- completion/bash_completion script (where _get_comp_words_by_ref is defined), I see that there is a function _init_completion that calls _get_comp_words_by_ref. I wonder if it wouldn't be simpler to just call "init_completion -n" instead of _get_comp_words_by_ref. This is the function that is used by the majority of completion scripts on my machine... Jonathon _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list