Skip to content

Commit 69ce136

Browse files
committed
fix: quote args in fish shell completion
The arguments used for dynamic completions in fish were missing quotes. This resulted in an error when one of the arguments had a `*` in it whose expansion matched no file. Once the completion got triggered, fish errored with the message `No matches for wildcard [...]`. Don't quote the first argument as that is the name of the binary.
1 parent 6dec1ae commit 69ce136

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fish_completions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ function __%[1]s_perform_completion
4646
4747
# Extract all args except the last one
4848
set -l args (commandline -opc)
49-
# Extract the last arg and escape it in case it is a space
49+
# Extract the last arg and escape it in case it is a space or wildcard
5050
set -l lastArg (string escape -- (commandline -ct))
5151
5252
__%[1]s_debug "args: $args"
5353
__%[1]s_debug "last arg: $lastArg"
5454
5555
# Disable ActiveHelp which is not supported for fish shell
56-
set -l requestComp "%[10]s=0 $args[1] %[3]s $args[2..-1] $lastArg"
56+
set -l requestComp "%[10]s=0 $args[1] %[3]s $(string join ' ' (string escape $args[2..-1])) $lastArg"
5757
5858
__%[1]s_debug "Calling $requestComp"
5959
set -l results (eval $requestComp 2> /dev/null)

0 commit comments

Comments
 (0)