Skip to content

Commit

Permalink
bug: quoting failure on windows-platform (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroWitzel authored and sharkdp committed Oct 5, 2023
1 parent 25331f8 commit bece2ea
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/benchmark/executor.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::os::windows::process::CommandExt;
use std::process::ExitStatus;

use crate::command::Command;
Expand Down Expand Up @@ -133,16 +134,23 @@ impl<'a> Executor for ShellExecutor<'a> {
command: &Command<'_>,
command_failure_action: Option<CmdFailureAction>,
) -> 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,
Expand Down

0 comments on commit bece2ea

Please sign in to comment.