From d2cec25395e01ded0977c1314e377cb24186c6c5 Mon Sep 17 00:00:00 2001 From: PiergiorgioZagaria Date: Tue, 30 Aug 2022 04:02:34 +0200 Subject: Fix process spawning error handling (#3349) * Fix process spawning error handling * Log stderr in any case--- helix-term/src/commands.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 885afa18..cb5460af 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4596,8 +4596,18 @@ fn shell_impl( } let output = process.wait_with_output()?; - if !output.stderr.is_empty() { - log::error!("Shell error: {}", String::from_utf8_lossy(&output.stderr)); + if !output.status.success() { + if !output.stderr.is_empty() { + let err = String::from_utf8_lossy(&output.stderr).to_string(); + log::error!("Shell error: {}", err); + bail!("Shell error: {}", err); + } + bail!("Shell command failed"); + } else if !output.stderr.is_empty() { + log::debug!( + "Command printed to stderr: {}", + String::from_utf8_lossy(&output.stderr).to_string() + ); } let str = std::str::from_utf8(&output.stdout) -- cgit v1.2.3-70-g09d2