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}() {
4646 flagPrefix="-P \${BASH_REMATCH}"
4747 fi
4848
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]}")
5151 if [ "\${lastChar}" = "" ]; then
5252 # If the last parameter is complete (there is a space following it)
5353 # We add an extra empty parameter so we can indicate this to the go completion code.
5454 __${ name } _debug "Adding extra empty parameter"
55- requestComp="\${requestComp} ''"
55+ args_to_quote+=("")
5656 fi
5757
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+
5864 __${ name } _debug "About to call: eval \${requestComp}"
5965
6066 # Use eval to handle any environment variables and such
You can’t perform that action at this time.
0 commit comments