diff options
-rwxr-xr-x | automated/lib/sh-test-lib | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib index 39a7e92..44f59fe 100755 --- a/automated/lib/sh-test-lib +++ b/automated/lib/sh-test-lib @@ -143,6 +143,20 @@ install_deps() { fi } +# Return the exit code of the first command when using pipe. +pipe0_status() { + [ "$#" -ne 2 ] && error_msg "Usage: pipe0_status cmd1 cmd2" + local cmd1="$1" + local cmd2="$2" + + exec 4>&1 + ret_val=$({ { eval "${cmd1}" 3>&-; echo "$?" 1>&3; } 4>&- \ + | eval "${cmd2}" 1>&4; } 3>&1) + exec 4>&- + + return "${ret_val}" +} + validate_check_sum() { if [ "$#" -ne 2 ]; then warn_msg "The number of parameters should be 2" |