rust-shell-script/rust_cmd_lib

How do I get the return code of the command?

NightMachinery opened this issue ยท 3 comments

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!("๐Ÿ‡บ๐Ÿ‡ธ" )
    }

$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/.

$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.