From e41af14b2a5e7643e4d4e882b20a828ef0104757 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Mon, 17 Oct 2022 19:51:25 +0900 Subject: feat(unstable): add windowsRawArguments to SpawnOptions (#16319) This change adds `windowsRawArguments` to `SpawnOptions`. The option enables skipping the default quoting and escaping while creating the command on windows. The option works in a similar way as `windowsVerbatimArguments` in child_process.spawn options in Node.js, and is necessary for simulating it in `std/node`. closes #8852 --- runtime/ops/spawn.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'runtime/ops') diff --git a/runtime/ops/spawn.rs b/runtime/ops/spawn.rs index 9286e6d0c..7fe77302a 100644 --- a/runtime/ops/spawn.rs +++ b/runtime/ops/spawn.rs @@ -17,6 +17,8 @@ use serde::Deserialize; use serde::Serialize; use std::borrow::Cow; use std::cell::RefCell; +#[cfg(windows)] +use std::os::windows::process::CommandExt; use std::process::ExitStatus; use std::rc::Rc; @@ -55,6 +57,8 @@ pub struct SpawnArgs { gid: Option, #[cfg(unix)] uid: Option, + #[cfg(windows)] + windows_raw_arguments: bool, #[serde(flatten)] stdio: ChildStdio, @@ -131,6 +135,17 @@ fn create_command( .check(&args.cmd, Some(api_name))?; let mut command = std::process::Command::new(args.cmd); + + #[cfg(windows)] + if args.windows_raw_arguments { + for arg in args.args.iter() { + command.raw_arg(arg); + } + } else { + command.args(args.args); + } + + #[cfg(not(windows))] command.args(args.args); if let Some(cwd) = args.cwd { -- cgit v1.2.3