diff options
| author | Kornel <kornel@geekhood.net> | 2021-05-30 17:01:02 +0100 |
|---|---|---|
| committer | Kornel <kornel@cloudflare.com> | 2021-07-09 14:09:48 +0100 |
| commit | d868da7796bfb96e87e09afc4e8338911b5f99b3 (patch) | |
| tree | 0d3c864b3127ed8f8a5c4a6cc42401064b915b4d /library/std/src/os | |
| parent | fcd5cecdcf50865df7838d734dfa5aeaa1f9c81e (diff) | |
| download | rust-d868da7796bfb96e87e09afc4e8338911b5f99b3.tar.gz rust-d868da7796bfb96e87e09afc4e8338911b5f99b3.zip | |
Unescaped command-line arguments for Windows
Fixes #29494
Diffstat (limited to 'library/std/src/os')
| -rw-r--r-- | library/std/src/os/windows/process.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/std/src/os/windows/process.rs b/library/std/src/os/windows/process.rs index 67756b15531..48c3d7bbd17 100644 --- a/library/std/src/os/windows/process.rs +++ b/library/std/src/os/windows/process.rs @@ -2,6 +2,7 @@ #![stable(feature = "process_extensions", since = "1.2.0")] +use crate::ffi::OsStr; use crate::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; use crate::process; use crate::sealed::Sealed; @@ -125,6 +126,13 @@ pub trait CommandExt: Sealed { /// [2]: <https://msdn.microsoft.com/en-us/library/17w5ykft.aspx> #[unstable(feature = "windows_process_extensions_force_quotes", issue = "82227")] fn force_quotes(&mut self, enabled: bool) -> &mut process::Command; + + /// Append literal text to the command line without any quoting or escaping. + /// + /// This is useful for passing arguments to `cmd.exe /c`, which doesn't follow + /// `CommandLineToArgvW` escaping rules. + #[unstable(feature = "windows_process_extensions_raw_arg", issue = "29494")] + fn raw_arg(&mut self, text_to_append_as_is: &OsStr) -> &mut process::Command; } #[stable(feature = "windows_process_extensions", since = "1.16.0")] @@ -138,4 +146,9 @@ impl CommandExt for process::Command { self.as_inner_mut().force_quotes(enabled); self } + + fn raw_arg(&mut self, raw_text: &OsStr) -> &mut process::Command { + self.as_inner_mut().raw_arg(raw_text); + self + } } |
