1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
macro_rules! sh {
    ($var:expr) => {
        let err = format!("Failed to execute {}", $var);
        let output = Command::new("sh").arg("-c").arg($var).output().expect(&err);

        if output.status.success() {
            // Print the stdout if the command executed successfully
            let stdout = String::from_utf8_lossy(&output.stdout);
            println!("Command output:\n{}", stdout);
        } else {
            // Print the stderr if the command failed
            let stderr = String::from_utf8_lossy(&output.stderr);
            println!("Command failed:\n{}", stderr);
        }
    };
}