#!/bin/bash # With -e -o pipefail, this script should exit immediately upon returning # from the pipeline, since grep does not match its string, and returns 1. # However, any trivial compound statement at the end of the pipeline will # cause the script to continue running. It's possible to work around the # problem by adding an extra piece to the end of the pipeline, so that it # ends with a simple statement, like | cat > /dev/null. But perhaps this # anomaly should be classified as a bug. I tested only with bash 3.0 and # 3.1, not 3.2.
set -e -o pipefail ss () { echo "subshell=$BASH_SUBSHELL" >&2 while read; do echo "input=$REPLY" >&2 done } echo "subshell=$BASH_SUBSHELL" >&2 echo 'abc' | grep 'xyz' | { ss; } echo "Why is this script still running? pipestatus = ${PIPESTATUS[*]}" _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash