diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2022-10-17 19:51:25 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 19:51:25 +0900 |
commit | e41af14b2a5e7643e4d4e882b20a828ef0104757 (patch) | |
tree | 272f45e879ea16217fea30842b22a0f7ba3a067d /runtime/ops/spawn.rs | |
parent | 0dc2f02dfa2b299cd8a8d352c880b05be463cf0f (diff) |
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
Diffstat (limited to 'runtime/ops/spawn.rs')
-rw-r--r-- | runtime/ops/spawn.rs | 15 |
1 files changed, 15 insertions, 0 deletions
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<u32>, #[cfg(unix)] uid: Option<u32>, + #[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 { |