File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -46,15 +46,21 @@ _${name}() {
46
46
flagPrefix="-P \${BASH_REMATCH}"
47
47
fi
48
48
49
- # Prepare the command to obtain completions
50
- requestComp=" ${ exec } complete -- \${words[2,-1]}"
49
+ # Prepare the command to obtain completions, ensuring arguments are quoted for eval
50
+ local -a args_to_quote=(" \${(@) words[2,-1]}")
51
51
if [ "\${lastChar}" = "" ]; then
52
52
# If the last parameter is complete (there is a space following it)
53
53
# We add an extra empty parameter so we can indicate this to the go completion code.
54
54
__${ name } _debug "Adding extra empty parameter"
55
- requestComp="\${requestComp} ''"
55
+ args_to_quote+=("")
56
56
fi
57
57
58
+ # Use Zsh's (q) flag to quote each argument safely for eval
59
+ local quoted_args=("\${(@q)args_to_quote}")
60
+
61
+ # Join the main command and the quoted arguments into a single string for eval
62
+ requestComp="${ exec } complete -- \${quoted_args[*]}"
63
+
58
64
__${ name } _debug "About to call: eval \${requestComp}"
59
65
60
66
# Use eval to handle any environment variables and such
You can’t perform that action at this time.
0 commit comments