From 1c492cb0cd65fef1efa3418457e0b394f9611d41 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 19 Apr 2025 13:09:42 +0200 Subject: pkgs/fupdate: Improve error reporting --- pkgs/by-name/fu/fupdate/src/main.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/fu/fupdate/src/main.rs b/pkgs/by-name/fu/fupdate/src/main.rs index 850eaf87..759f65ec 100644 --- a/pkgs/by-name/fu/fupdate/src/main.rs +++ b/pkgs/by-name/fu/fupdate/src/main.rs @@ -12,7 +12,7 @@ fn main() -> Result<(), anyhow::Error> { let args = CliArgs::parse(); - let other = args.command.first().map_or("flake", String::as_str); + let command = args.command.first().map_or("flake", String::as_str); { let args = if args.command.len() > 1 { @@ -21,13 +21,19 @@ fn main() -> Result<(), anyhow::Error> { &[] }; - let status = Command::new(format!("fupdate-{other}")) - .args(args) - .status() - .with_context(|| format!("Failed to execute `fupdate-{other}`"))?; + // println!("Running: `fupdate-{command} {}`", args.join(" ")); - if !status.success() { - bail!("Command `fupdate-{other}` failed!"); + let mut child = Command::new(format!("fupdate-{command}")) + .args(args) + .spawn() + .with_context(|| format!("Failed to spawn `fupdate-{command}`"))?; + + if !child + .wait() + .with_context(|| format!("Failed to wait for `fupdate-{command}` to finish"))? + .success() + { + bail!("Command `fupdate-{command} {}` failed!", args.join(" ")); } } -- cgit 1.4.1