Make exit code propagate
This commit is contained in:
parent
28934ea6fc
commit
07b0403e9b
@ -105,13 +105,14 @@ fn find_objectfile(name: &str) -> String {
|
|||||||
.to_owned()
|
.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(path: &PathBuf) {
|
pub fn execute(path: &PathBuf) -> Option<i32> {
|
||||||
let output = Command::new(path.clone()).output().expect("Unable to execute {path}");
|
let output = Command::new(path.clone()).output().expect("Unable to execute {path}");
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
let code = output.status.code().unwrap_or(255);
|
let code = output.status.code().unwrap_or(255);
|
||||||
log::error!("{path:?} exited with code {code}");
|
log::error!("{path:?} exited with code {code}");
|
||||||
println!("{}", unsafe { String::from_utf8_unchecked(output.stderr) });
|
println!("{}", unsafe { String::from_utf8_unchecked(output.stderr) });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output.status.code()
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf, process};
|
||||||
|
|
||||||
use argh::FromArgs;
|
use argh::FromArgs;
|
||||||
use log::*;
|
use log::*;
|
||||||
@ -139,7 +139,9 @@ fn main() {
|
|||||||
match &options.command {
|
match &options.command {
|
||||||
Command::Build(_) => {}
|
Command::Build(_) => {}
|
||||||
Command::Run(_) => {
|
Command::Run(_) => {
|
||||||
execute(&out_path);
|
if let Some(code) = execute(&out_path) {
|
||||||
|
process::exit(code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user