diff --git a/src/shell.rs b/src/shell.rs index 71d2367..0faa13c 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -26,12 +26,23 @@ pub fn command_output(shell: &str, command: &str) -> String { }); match receiver.recv_timeout(Duration::from_secs(3)) { - Ok(output) => String::from_utf8_lossy(&output.stderr) - .to_string() - .split_whitespace() - .collect::>() - .join(" ") - .to_lowercase(), + Ok(output) => { + if !output.stderr.is_empty() { + String::from_utf8_lossy(&output.stderr) + .to_string() + .split_whitespace() + .collect::>() + .join(" ") + .to_lowercase() + } else { + String::from_utf8_lossy(&output.stdout) + .to_string() + .split_whitespace() + .collect::>() + .join(" ") + .to_lowercase() + } + } Err(_) => { use colored::*; eprintln!("Timeout while executing command: {}", command.red());