bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pipefail bug


From: John Kelly
Subject: pipefail bug
Date: Sat, 02 Dec 2006 23:37:29 +0000

#!/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[*]}"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]