You have to use
set -o pipefail
See this related StackOverflow Question.
Minimal example:
#!/bin/bashtrap handler ERRhandler() { echo trapped ; }echo 1false | :echo 2set -o pipefailfalse | :
Output:
$ bash test.sh12trapped