Only escape backslash on windows (#825)

This commit is contained in:
JT 2022-01-22 18:35:52 -05:00 committed by GitHub
parent 310ecb79b6
commit bf9340ec48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -277,9 +277,21 @@ impl<'call> ExternalCommand<'call> {
head head
}; };
let head = head.replace("\\", "\\\\"); //let head = head.replace("\\", "\\\\");
let mut process = std::process::Command::new(&head); let new_head;
#[cfg(windows)]
{
new_head = head.replace("\\", "\\\\");
}
#[cfg(not(windows))]
{
new_head = head;
}
let mut process = std::process::Command::new(&new_head);
for arg in &self.args { for arg in &self.args {
let arg = trim_enclosing_quotes(arg); let arg = trim_enclosing_quotes(arg);
@ -291,9 +303,19 @@ impl<'call> ExternalCommand<'call> {
arg arg
}; };
let arg = arg.replace("\\", "\\\\"); let new_arg;
process.arg(&arg); #[cfg(windows)]
{
new_arg = arg.replace("\\", "\\\\");
}
#[cfg(not(windows))]
{
new_arg = arg;
}
process.arg(&new_arg);
} }
process process