Skip to content
Myr

fix: quote args in fish shell completion (#2285)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* 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. * Protect against arguments that start with -- Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com> ---------

authored by Niklas Vogel · committed by GitHub · parent 10d4b48 · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:fish_completions.go+2 added-2 removed
44 unmodified lines
45 __%[1]s_debug "Starting __%[1]s_perform_completion"4647 # Extract all args except the last one48 set -l args (commandline -opc)49 # Extract the last arg and escape it in case it is a space49 # Extract the last arg and escape it in case it is a space or wildcard50 set -l lastArg (string escape -- (commandline -ct))5152 __%[1]s_debug "args: $args"53 __%[1]s_debug "last arg: $lastArg"5455 # Disable ActiveHelp which is not supported for fish shell56 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"5758 __%[1]s_debug "Calling $requestComp"59 set -l results (eval $requestComp 2> /dev/null)60
232 unmodified lines