作者:鬼鬼太子_157 | 来源:互联网 | 2023-06-27 20:32
Rust Version
rustc 1.38.0 (625451e37 2019-09-23)
Affected Version of clap
clap 2.33.0
Expected Behavior Summary
Generated Zsh completions correctly complete
even in the presence of characters that have a special meaning for the shell
Actual Behavior Summary
For example, when some string in
contains
(a pipe) the generated completion script fails with
1
| (eval):1: parse error near `|' |
when pressing tab for that argument.
That was the problem I ran into. I then tested some other special characters.
A sample of the characters I found to have problems:
-
breaks completion script
1
| (eval):1: parse error near `|' |
-
splits completion value into two
-
makes whole value not show up in completions
-
makes whole value not show up in completions
-
breaks completion script
-
breaks completion script
1
| (eval):1: unmatched ` |
-
interpreted as https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html when followed by some other chars
-
makes whole value not show up in completions
There are more special characters, that need to be escaped. The reproduction from the repo tests against all non control ascii characters and some dollar-something strings.
Steps to Reproduce the issue
Sample Code or Link to Sample Code
https://github.com/succcubbus/clap-zsh-completions-repro
Debug output
https://pastebin.com/KU4yd6FR
该提问来源于开源项目:clap-rs/clap
But I don't think there are any crates that do this.