fix: use stderr if stdout is empty

This commit is contained in:
iff 2024-12-08 11:19:54 +01:00
parent 21ded71ab6
commit f14a1c1ea7

View file

@ -235,7 +235,10 @@ pub fn command_output(shell: &str, command: &str) -> String {
.output() .output()
.expect("failed to execute process"); .expect("failed to execute process");
String::from_utf8_lossy(&output.stdout).to_string() match output.stdout.is_empty() {
false => String::from_utf8_lossy(&output.stdout).to_lowercase(),
true => String::from_utf8_lossy(&output.stderr).to_lowercase(),
}
} }
pub fn last_command(shell: &str) -> String { pub fn last_command(shell: &str) -> String {