Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

sudotac
Copy link
Contributor

@sudotac sudotac commented Feb 2, 2024

Fix #5313 (and continuation of #5240)

The root cause is field splitting by bash.
It is erroneously performed when processing compgen output.
The delimiters used for field splitting are defined in IFS environment variable, which is $' \t\n' (space, tab, newline) by default. If the output of compgen contains these characters, they are split out.

This patch (partially) fixes that by restricting IFS to newline.
Now we can handle filenames with spaces and/or tabs, but not newlines because we cannot distinguish "newline as a delimiter" from "newline contained in filename".

Handling newlines would be more difficult than handling spaces. It seems that other completion scripts cannot handle this.
I think this should be a separate issue if we really try to fix this.

@epage
Copy link
Member

epage commented Feb 2, 2024

Thanks!

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.

clap_complete bash: filenames with spaces are not completed properly
2 participants