From 7a9725b5878c945ad342d754eeae476834096110 Mon Sep 17 00:00:00 2001 From: Jeffrey Faer Date: Thu, 5 Dec 2024 21:33:06 -0700 Subject: [PATCH] Only quote the last arg. The other ones should already have been quoted by the completion script. Signed-off-by: Jeffrey Faer --- bash_completionsV2.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bash_completionsV2.go b/bash_completionsV2.go index ff4df32..c57c06b 100644 --- a/bash_completionsV2.go +++ b/bash_completionsV2.go @@ -61,7 +61,10 @@ __%[1]s_get_completion_results() { args=("${words[@]:1}") requestComp="${words[0]} %[2]s" if [[ "${#args[@]}" -gt 0 ]]; then - requestComp+="$(printf " %%q" "${args[@]}")" + # Previous args should already be escaped... + requestComp+=" ${args[*]::${#args[@]}-1}" + # ...but the current arg might not yet be escaped. + requestComp+=" $(printf "%%q" "${args[${#args[@]}-1]}")" fi lastParam=${words[$((${#words[@]}-1))]}