Make exit code propagate

This commit is contained in:
Sofia 2025-08-17 17:47:59 +03:00
parent 28934ea6fc
commit 07b0403e9b
2 changed files with 7 additions and 4 deletions

View File

@ -105,13 +105,14 @@ fn find_objectfile(name: &str) -> String {
.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}");
if !output.status.success() {
let code = output.status.code().unwrap_or(255);
log::error!("{path:?} exited with code {code}");
println!("{}", unsafe { String::from_utf8_unchecked(output.stderr) });
return;
}
output.status.code()
}

View File

@ -1,4 +1,4 @@
use std::{fs, path::PathBuf};
use std::{fs, path::PathBuf, process};
use argh::FromArgs;
use log::*;
@ -139,7 +139,9 @@ fn main() {
match &options.command {
Command::Build(_) => {}
Command::Run(_) => {
execute(&out_path);
if let Some(code) = execute(&out_path) {
process::exit(code);
}
}
}
}