From bece2eacf0939f376c9f046ee0bacc794e2a5ffe Mon Sep 17 00:00:00 2001 From: Pedro Witzel Date: Mon, 28 Aug 2023 22:12:22 +0200 Subject: [PATCH] bug: quoting failure on windows-platform (#296) --- src/benchmark/executor.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/benchmark/executor.rs b/src/benchmark/executor.rs index 31db47ba6..9707b4e44 100644 --- a/src/benchmark/executor.rs +++ b/src/benchmark/executor.rs @@ -1,3 +1,4 @@ +use std::os::windows::process::CommandExt; use std::process::ExitStatus; use crate::command::Command; @@ -133,16 +134,23 @@ impl<'a> Executor for ShellExecutor<'a> { command: &Command<'_>, command_failure_action: Option, ) -> Result<(TimingResult, ExitStatus)> { + let on_windows_cmd = cfg!(windows) && *self.shell == Shell::Default("cmd.exe"); let mut command_builder = self.shell.command(); command_builder .arg( - if cfg!(windows) && *self.shell == Shell::Default("cmd.exe") { + if on_windows_cmd { "/C" } else { "-c" }, - ) - .arg(command.get_command_line()); + ); + + // Windows needs special treatment for its behavior on parsing cmd arguments + if on_windows_cmd { + command_builder.raw_arg(command.get_command_line()); + } else { + command_builder.arg(command.get_command_line()); + } let mut result = run_command_and_measure_common( command_builder,