cobra icon indicating copy to clipboard operation
cobra copied to clipboard

fix: quote args in fish shell completion

Open n9v9 opened this issue 5 months ago • 2 comments

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.

Closes #1933

n9v9 avatar Jun 11 '25 10:06 n9v9

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 11 '25 10:06 CLAassistant

This seemed reasonable but when I run the tests in https://github.com/marckhouzam/cobra-completion-testing I'm getting failures. I haven't investigated yet.

marckhouzam avatar Dec 09 '25 02:12 marckhouzam

I pushed a commit on top of the PR to properly handle when the arguments are flags. The the problem was that when completing something like "prog --hello <TAB>" the new string join and string escape commands in the fish scripts would receive --hello and would treat it as a flag instead of an argument. By using string join -- and string escape -- we tell fish that all arguments following the -- are not to be treated as flags.

marckhouzam avatar Dec 10 '25 02:12 marckhouzam