mirror of
https://github.com/spf13/cobra
synced 2025-04-27 17:17:20 +00:00
Only quote the last arg.
The other ones should already have been quoted by the completion script. Signed-off-by: Jeffrey Faer <jeffrey.faer@gmail.com>
This commit is contained in:
parent
df206d9f38
commit
7a9725b587
1 changed files with 4 additions and 1 deletions
|
@ -61,7 +61,10 @@ __%[1]s_get_completion_results() {
|
||||||
args=("${words[@]:1}")
|
args=("${words[@]:1}")
|
||||||
requestComp="${words[0]} %[2]s"
|
requestComp="${words[0]} %[2]s"
|
||||||
if [[ "${#args[@]}" -gt 0 ]]; then
|
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
|
fi
|
||||||
|
|
||||||
lastParam=${words[$((${#words[@]}-1))]}
|
lastParam=${words[$((${#words[@]}-1))]}
|
||||||
|
|
Loading…
Add table
Reference in a new issue