As man bashexplains
Each command in the pipeline is executed as a separate process (i.e., in a subshell).
Consequently, exitthe function only leaves a subshell, which starts the functional part of the pipeline.
As well as
The return status of the pipeline is the exit status of the last command, if the option is not enabled pipefail.
Therefore, you can change the behavior by adding
set -eo pipefail
script (-e script ). , , exit 0 .