Closed PacifiK2460 closed 2 weeks ago
What OS and shell are you using?
Could you add the Debug Output?
Quoting is machine dependent. On Windows, its usually controlled by libc/stdlib. On other platforms, its usually controlled by the shell. Looking at the Debug Output can confirm what clap is getting.
@epage, it looks like the first argument gets the correct value, but the next string argument gets the remaining arguments as a string:
If I run it with the arguments -i '.\directory\' -c 9 -l 'powershell.exe -File .\install.ps1'
, I get error: unexpected argument '-F' found.
If I run it with -l 'powershell.exe -File .\install.ps1' -i '.\dir\' -c 9
, I get instead ERR: ".\\dir\" -c 9" is not a directory.
(The error is from later code where I check if the input directory is existent.)
Looking at the debug output, it appears this is all a matter of how quoting works in the Rust standard library when it parses the command line.
You can confirm this by trying your inputs on
fn main() {
dbg!(std::env::args());
}Could you try those with
As such, there isn't anything clap can or should do and I'm going to go ahead and close this. If there is a reason to keep this re-evaluate this, let us know!
Please complete the following tasks
Rust Version
rustc 1.78.0 (9b00956e5 2024-04-29) (Windows 11, Powershell)
Clap Version
4.5.6
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run -- -l 'powershell.exe -File .\install.ps1'
Actual Behaviour
Expected Behaviour
Should get the
launch
argument as a single string with the value of 'powershell.exe -File .\install.ps1'Additional Context
Just that problem, I knew that my argument would be better to be quoted since it'll part of user input (therefore I won't know the lenght of the argument)
Debug Output
for:
-i '.\dir\' -c 9 -l 'powershell.exe -File .\install.ps1'