Exit when one process in pipe fails

I think that you’re looking for the pipefail option. From the bash man page:

pipefail

If set, the return value of a pipeline is the value of the last (rightmost)
command to exit with a non-zero status, or zero if all commands in the
pipeline exit successfully. This option is disabled by default.

So if you start your wrapper script with

#!/bin/bash

set -e
set -o pipefail

Then the wrapper will exit when any error occurs (set -e) and will set the status of the pipeline in the way that you want.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)