Skip to content

Conversation

@n9v9
Copy link
Contributor

@n9v9 n9v9 commented Jun 11, 2025

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

@CLAassistant
Copy link

CLAassistant commented Jun 11, 2025

CLA assistant check
All committers have signed the CLA.

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.
@n9v9 n9v9 force-pushed the issue-1933/quote-fish-args branch from 5eac3d8 to 69ce136 Compare June 11, 2025 14:17
@marckhouzam
Copy link
Collaborator

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.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
@marckhouzam
Copy link
Collaborator

marckhouzam commented Dec 10, 2025

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 " 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.

Copy link
Collaborator

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@marckhouzam marckhouzam merged commit 61968e8 into spf13:main Dec 10, 2025
21 checks passed
@marckhouzam marckhouzam added this to the 1.11.0 milestone Dec 10, 2025
@n9v9 n9v9 deleted the issue-1933/quote-fish-args branch December 10, 2025 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

command line args should be quoted in generated fish completion script

4 participants