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))]}