cli: improve handling of quoting in bash completion

_init_completion returns the '${words[@]}' array with all the
quotes and escapes. We dont care about it so we drop (unescape)
first.

Before, the following failed:

  nmcli 'c' <TAB>
  nmcli connection modify id Wireless\ Connection\ 1 <TAB>

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2013-11-12 18:19:05 +01:00
parent 0e5de01cc8
commit ed60815d4c

View file

@ -538,6 +538,12 @@ _nmcli()
# right of the cursor, just ignore them. Also don't care about ${words[0]}.
words=("${words[@]:1:$cword}")
# _init_completion returns the words with all the quotes and escaping
# characters. We don't care about them, drop them at first.
for i in ${!words[*]}; do
words[i]="$(echo "${words[i]}" | xargs 2>/dev/null || true)"
done
_nmcli_complete_OPTIONS && return 0
local command="${words[1]}"