mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
fix: fallback to stdout if stderr is empty
This commit is contained in:
parent
96a588799d
commit
adfedfad3d
1 changed files with 17 additions and 6 deletions
23
src/shell.rs
23
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::<Vec<&str>>()
|
||||
.join(" ")
|
||||
.to_lowercase(),
|
||||
Ok(output) => {
|
||||
if !output.stderr.is_empty() {
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
.to_string()
|
||||
.split_whitespace()
|
||||
.collect::<Vec<&str>>()
|
||||
.join(" ")
|
||||
.to_lowercase()
|
||||
} else {
|
||||
String::from_utf8_lossy(&output.stdout)
|
||||
.to_string()
|
||||
.split_whitespace()
|
||||
.collect::<Vec<&str>>()
|
||||
.join(" ")
|
||||
.to_lowercase()
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
use colored::*;
|
||||
eprintln!("Timeout while executing command: {}", command.red());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue