help-bash
[Top][All Lists]
Advanced

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

Automatically use redirection to capture return status of unnamed pipe?


From: Peng Yu
Subject: Automatically use redirection to capture return status of unnamed pipe?
Date: Fri, 27 Mar 2020 19:45:59 -0500

Hi,

In the following command, the return status does not capture the
errors in the unnamed pipes.

set -o pipefail
paste <(seq 3; false) <(seq 11 13; false) || echo "$?"
1       11
2       12
3       13

The following command is equivalent to the above command, except that
the return status captures the error. But the code is less readable.

{ seq 3; false; } | {
        { seq 11 13; false; } | paste /dev/fd/3 /dev/fd/4 4<&0
} 3<&0 || echo "$?"
1       11
2       12
3       13
1

Is there an automatic internal translation of the code in bash so that
the first command can be still used and the errors are still captured?
Thanks.

-- 
Regards,
Peng



reply via email to

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