Merge pull request #71 from jonathandturner/fix_linux

Fix linux shell support
This commit is contained in:
Jonathan Turner 2019-06-02 19:52:56 +12:00 committed by GitHub
commit dd5728ddc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,28 +133,59 @@ impl ExternalCommand {
arg_string.push_str(" "); arg_string.push_str(" ");
arg_string.push_str(&arg); arg_string.push_str(&arg);
} }
let mut process = Exec::shell(&self.name);
if arg_string.contains("$it") { let mut process;
let mut first = true; #[cfg(windows)]
for i in &inputs { {
if !first { process = Exec::shell(&self.name);
process = process.arg("&&");
process = process.arg(&self.name); if arg_string.contains("$it") {
} else { let mut first = true;
first = false; for i in &inputs {
if !first {
process = process.arg("&&");
process = process.arg(&self.name);
} else {
first = false;
}
for arg in &self.args {
process = process.arg(&arg.replace("$it", &i.as_string().unwrap()));
}
} }
} else {
for arg in &self.args { for arg in &self.args {
process = process.arg(&arg.replace("$it", &i.as_string().unwrap())); process = process.arg(arg);
} }
} }
} else {
for arg in &self.args {
process = process.arg(arg);
}
} }
#[cfg(not(windows))]
{
let mut new_arg_string = self.name.to_string();
if arg_string.contains("$it") {
let mut first = true;
for i in &inputs {
if !first {
new_arg_string.push_str(" && ");
new_arg_string.push_str(&self.name);
} else {
first = false;
}
for arg in &self.args {
new_arg_string.push_str(" ");
new_arg_string.push_str(&arg.replace("$it", &i.as_string().unwrap()));
}
}
} else {
for arg in &self.args {
new_arg_string.push_str(" ");
new_arg_string.push_str(&arg);
}
}
process = Exec::shell(new_arg_string);
}
process = process.cwd(context.env.lock().unwrap().cwd()); process = process.cwd(context.env.lock().unwrap().cwd());
let mut process = match stream_next { let mut process = match stream_next {