bug: quoting failure on windows-platform (#296)

This commit is contained in:
Pedro Witzel authored and David Peter committed 2023-10-05 09:25:07 +02:00
1 parent 25331f89f9
commit bece2eacf0
1 file changed
+11 -3
+11 -3
View File
@@ -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<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,