mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 22:40:09 +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)) {
|
match receiver.recv_timeout(Duration::from_secs(3)) {
|
||||||
Ok(output) => String::from_utf8_lossy(&output.stderr)
|
Ok(output) => {
|
||||||
.to_string()
|
if !output.stderr.is_empty() {
|
||||||
.split_whitespace()
|
String::from_utf8_lossy(&output.stderr)
|
||||||
.collect::<Vec<&str>>()
|
.to_string()
|
||||||
.join(" ")
|
.split_whitespace()
|
||||||
.to_lowercase(),
|
.collect::<Vec<&str>>()
|
||||||
|
.join(" ")
|
||||||
|
.to_lowercase()
|
||||||
|
} else {
|
||||||
|
String::from_utf8_lossy(&output.stdout)
|
||||||
|
.to_string()
|
||||||
|
.split_whitespace()
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.join(" ")
|
||||||
|
.to_lowercase()
|
||||||
|
}
|
||||||
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
use colored::*;
|
use colored::*;
|
||||||
eprintln!("Timeout while executing command: {}", command.red());
|
eprintln!("Timeout while executing command: {}", command.red());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue