How do I get the return code of the command?
NightMachinery opened this issue ยท 3 comments
NightMachinery commented
I tried this but it did not work:
if run_fun!(rg --quiet -F "LayoutTU.S." $HOME/Library/Preferences/com.apple.HIToolbox.plist).is_err() {
println!("๐ฎ๐ท" )
} else {
println!("๐บ๐ธ" )
}
tao-guo commented
$HOME is a sh/bash variable, and you can use std::env::var instead. For printing error messages from result, check https://doc.rust-lang.org/std/result/.
NightMachinery commented
$HOME is a sh/bash variable, and you can use std::env::var instead. For printing error messages from result, check https://doc.rust-lang.org/std/result/.
I know, I have set HOME in a var before this code snippet. I do not want to get the error message; I just need the exit code.
tao-guo commented
You can try this: https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error