From ed60815d4c26b7ea8bead439abb9a02f8c80a1b6 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 12 Nov 2013 18:19:05 +0100 Subject: [PATCH] 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' nmcli connection modify id Wireless\ Connection\ 1 Signed-off-by: Thomas Haller --- cli/completion/nmcli | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/completion/nmcli b/cli/completion/nmcli index c5e520362d..9eabc213e3 100644 --- a/cli/completion/nmcli +++ b/cli/completion/nmcli @@ -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]}"