From d2801410c36f9dd5ef28a19f97310814f749ee5d Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 13 Feb 2024 21:47:08 +0100 Subject: [PATCH] fix: also show script stderr --- src/main.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 39c75a6..04289df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,13 +57,17 @@ fn main() { fn shell>(cmd: S) -> std::io::Result { let output = std::process::Command::new(cmd).output()?; - match std::str::from_utf8(&output.stdout) { - Ok(s) => Ok(s.to_string()), - Err(e) => { - println!("[?] shell produced non-utf8 output ({e})"); - Ok(format!("{:?}", output.stdout)) - }, - } + let stderr = match std::str::from_utf8(&output.stderr) { + Ok(s) => s.to_string(), + Err(_) => format!("{:?}", output.stderr), + }; + + let stdout = match std::str::from_utf8(&output.stdout) { + Ok(s) => s.to_string(), + Err(_) => format!("{:?}", output.stdout), + }; + + Ok(format!("{stderr}{stdout}")) } fn tci(cfg: TciConfig) -> Result<(), Box> {