From 7e74fc8888ac525316416017594b0ad563a2d49e Mon Sep 17 00:00:00 2001 From: Quantum Date: Tue, 15 Oct 2024 02:02:39 -0400 Subject: [PATCH] Forward child process return code if possible --- src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 75d4ca4..5343fd5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use crate::runner::CaptureError; use clap::Parser; use runner::CapturedOutput; +use std::process::exit; mod quote; mod runner; @@ -210,7 +211,13 @@ async fn main() { }; match request.send().await.and_then(|r| r.error_for_status()) { - Ok(_) => (), - Err(error) => eprintln!("Failed to send request to ntfy: {}", error), + Ok(_) => exit(match status { + Some(code) => code.code().unwrap_or(255), + None => 255, + }), + Err(error) => { + eprintln!("Failed to send request to ntfy: {}", error); + exit(37) + } } }