help-bash
[Top][All Lists]
Advanced

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

Re: Automatically use redirection to capture return status of unnamed pi


From: Peng Yu
Subject: Re: Automatically use redirection to capture return status of unnamed pipe?
Date: Mon, 6 Apr 2020 20:28:32 -0500

I also notice that bash will count down fd from 63 to 3 then count up
fd from 64. Could this cause any conflict if I uses some fd that bash
uses automatically? Thanks.

$ echo <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
<(echo x) <(echo x) <(echo x) <(echo x) <(echo x) <(echo x)
/dev/fd/63 /dev/fd/62 /dev/fd/61 /dev/fd/60 /dev/fd/59 /dev/fd/58
/dev/fd/57 /dev/fd/56 /dev/fd/55 /dev/fd/54 /dev/fd/53 /dev/fd/52
/dev/fd/51 /dev/fd/50 /dev/fd/49 /dev/fd/48 /dev/fd/47 /dev/fd/46
/dev/fd/45 /dev/fd/44 /dev/fd/43 /dev/fd/42 /dev/fd/41 /dev/fd/40
/dev/fd/39 /dev/fd/38 /dev/fd/37 /dev/fd/36 /dev/fd/35 /dev/fd/34
/dev/fd/33 /dev/fd/32 /dev/fd/31 /dev/fd/30 /dev/fd/29 /dev/fd/28
/dev/fd/27 /dev/fd/26 /dev/fd/25 /dev/fd/24 /dev/fd/23 /dev/fd/22
/dev/fd/21 /dev/fd/20 /dev/fd/19 /dev/fd/18 /dev/fd/17 /dev/fd/16
/dev/fd/15 /dev/fd/14 /dev/fd/13 /dev/fd/12 /dev/fd/11 /dev/fd/10
/dev/fd/9 /dev/fd/8 /dev/fd/7 /dev/fd/6 /dev/fd/5 /dev/fd/3 /dev/fd/4
/dev/fd/64 /dev/fd/65 /dev/fd/66 /dev/fd/67 /dev/fd/68 /dev/fd/69
/dev/fd/70


On 3/27/20, Peng Yu <address@hidden> wrote:
> 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
>


-- 
Regards,
Peng



reply via email to

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