command line args should be quoted in generated fish completion script
more specifically here in fish_completions.go:56:
set -l requestComp "%[10]s=0 $args[1] %[3]s $args[2..-1] $lastArg"
where the references $args[1], $args[2..-1] and $lastArg should have been quoted.
Downstream issue: https://github.com/mikefarah/yq/issues/1502
An easy fix would be just quote the referenced args:
set -l requestComp "%[9]s=0 '$args[1]' %[3]s '$args[2..-1]' '$lastArg'"
But I'm not sure what would happen if $args[2..-1] includes more than one list items, hopefully there's something equivalent to quoted array expansion like "${array[@]}" in bash.
I stumbled upon the same issue. Regarding quoting $args[2..-1], the following works:
set -l requestComp "%[10]s=0 '$args[1]' %[3]s $(string join ' ' (string escape $args[2..-1])) '$lastArg'"
%[10]s=0 is just the value from the current main branch.
As a workaround, without having to redefine the whole completion command, it's possible to intercept the completion fish command via PersistentPreRunE on the root command, generate the completions manually and write them into a buffer via rootCmd.GenFishCompletion(...), and then just replace the lines and output them.
It seems to me this old issue is still there.
I'm glad @n9v9 took the time to look at it, and provide an update and feedbacks here.
Thanks
Do you think you could open a PR ? I feel like you are close to a fix, no?