From 07b0403e9b0fb5f3460afc6a553f7885e4199aad Mon Sep 17 00:00:00 2001 From: sofia Date: Sun, 17 Aug 2025 17:47:59 +0300 Subject: [PATCH] Make exit code propagate --- reid/src/ld.rs | 5 +++-- reid/src/main.rs | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/reid/src/ld.rs b/reid/src/ld.rs index 1558d0e..8f5fde2 100644 --- a/reid/src/ld.rs +++ b/reid/src/ld.rs @@ -105,13 +105,14 @@ fn find_objectfile(name: &str) -> String { .to_owned() } -pub fn execute(path: &PathBuf) { +pub fn execute(path: &PathBuf) -> Option { 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() } diff --git a/reid/src/main.rs b/reid/src/main.rs index 07c5f41..1d0c9f3 100644 --- a/reid/src/main.rs +++ b/reid/src/main.rs @@ -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); + } } } }