summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2013-11-12 18:19:05 +0100
committerThomas Haller <thaller@redhat.com>2013-11-12 18:49:03 +0100
commited60815d4c26b7ea8bead439abb9a02f8c80a1b6 (patch)
treee8dbd61ced221f6d5a7574b3ac1187d6d8624ae8
parent0e5de01cc857758579b857071d9bbeebfc3af090 (diff)
downloadNetworkManager-ed60815d4c26b7ea8bead439abb9a02f8c80a1b6.tar.gz
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>
-rw-r--r--cli/completion/nmcli6
1 files changed, 6 insertions, 0 deletions
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]}"