Skip to content

support pipefail #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2020
Merged

Conversation

gdetal
Copy link
Contributor

@gdetal gdetal commented Oct 19, 2020

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:

  • without pipefail (default behavior):
run_cmd!(cat` /non-existant | wc -l)?; // returns Ok(())
  • with pipefail:
proc_env_set!(CMD_LIB_PIPE_FAIL = 1);
run_cmd!(cat /non-existant | wc -l)?; // Returns Err(_)

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:

- without pipefail (default behavior):

  run_cmd!(cat /non-existant | wc -l)?; // returns Ok(())

- with pipefail:

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

Signed-off-by: Gregory Detal <gregory.detal@tessares.net>
@rust-shell-script rust-shell-script merged commit 633766a into rust-shell-script:master Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants