rust-shell-script / rust_cmd_lib

Common rust command-line macros and utilities, to write shell-script like tasks in a clean, natural and rusty way
https://docs.rs/cmd_lib/
Apache License 2.0
1.05k stars 37 forks source link

support pipefail #16

Closed gdetal closed 4 years ago

gdetal commented 4 years ago

This commit adds the option CMD_LIB_PIPE_FAIL. If set to 1 this will cause both run_cmd!() and run_fun!() to return an error when at least one command fails. This actually implements a similar behavior as -o pipefail from bash.

Example:

run_cmd!(cat` /non-existant | wc -l)?; // returns Ok(())
proc_env_set!(CMD_LIB_PIPE_FAIL = 1);
run_cmd!(cat /non-existant | wc -l)?; // Returns Err(_)