First thing you want is set -e and set -o pipefail. That should report the errors in human-parseable form.
Second, to capture exit codes from each command/program, you have to run each of them in sequence yourself, connected by pipes that you create via mkfifo — the same way as you would do it in any other programming environment. Bash’s | pipes are just a convenient shorthand for this,so if you want full control, you have to ditch the convenience.
First thing you want is
set -eandset -o pipefail. That should report the errors in human-parseable form.Second, to capture exit codes from each command/program, you have to run each of them in sequence yourself, connected by pipes that you create via
mkfifo— the same way as you would do it in any other programming environment. Bash’s|pipes are just a convenient shorthand for this,so if you want full control, you have to ditch the convenience.