-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Command::raw_arg
on Windows
#5810
Comments
CMD uses special handling for arguments to passed to /C. Unfortunately, this causes errors with quoted program names in these arguments. This commit implements a workaround: When CMD is requested, we build a std::process::Command and pass the the argument to /C using the special std::os::windows::process::CommandExt::raw_arg method. The StdCommand is then converted to a TokioCommand and returned. Once tokio-rs/tokio#5810 is fixed, this workaround can be removed. Fixes watchexec#613
CMD uses special handling for arguments to passed to /C. Unfortunately, this causes errors with quoted program names in these arguments. This commit implements a workaround: When CMD is requested, we build a std::process::Command and pass the argument to /C using the special std::os::windows::process::CommandExt::raw_arg method. The StdCommand is then converted to a TokioCommand and returned. Once tokio-rs/tokio#5810 is fixed, this workaround can be removed. Fixes watchexec#613
I already implemented that (#5704) and it’s an unstable feature since tokio v1.29.0. But I don’t know why it doesn’t show up in the docs. |
Apologies, I did only search for I think it's not listed on So, now it's just a matter of waiting for |
Is your feature request related to a problem? Please describe.
In watchexec/watchexec#613, it was discovered that CMD does not handle quoted arguments properly. This is known behaviour and led to the inclusion of a
CommandExt::raw_arg
method instd
.Describe the solution you'd like
For parity with
std
, it would be nice to implementCommand::raw_arg
on Windows.Describe alternatives you've considered
As a workaround, users can create a
StdCommand
and convert this totokio
'sCommand
using the providedFrom
implementation. However, this means two additional imports (StdCommand
andCommandExt
), and might potentially confuse users. It's also not as nice to use since method chaining is no longer possible.Additional context
I've included three example programs to demonstrate the issue when using
tokio
, a solution using onlystd
, and the workaround described above.Problematic
tokio
code:Pure
std
solution:Workaround using conversion from
StdCommand
:The text was updated successfully, but these errors were encountered: