From 29a6f468a683ec5f955a794291768f04ef999699 Mon Sep 17 00:00:00 2001 From: Joris Kleiber Date: Fri, 19 May 2023 15:42:38 +0200 Subject: [PATCH] process: add `raw_arg` method to `Command` (#5704) --- tokio/src/process/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index 58c50aa8a..8b22cfbe1 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -400,6 +400,22 @@ impl Command { self } + /// 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. + /// + /// **Note**: This is an [unstable API][unstable] but will be stabilised once + /// tokio's MSRV is sufficiently new. See [the documentation on + /// unstable features][unstable] for details about using unstable features. + #[cfg(windows)] + #[cfg(tokio_unstable)] + #[cfg_attr(docsrs, doc(cfg(all(windows, tokio_unstable))))] + pub fn raw_arg>(&mut self, text_to_append_as_is: S) -> &mut Command { + self.std.raw_arg(text_to_append_as_is); + self + } + /// Inserts or updates an environment variable mapping. /// /// Note that environment variable names are case-insensitive (but case-preserving) on Windows,