[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to catch errors in "readarray ... < <(...)"
From: |
Pierre Gaston |
Subject: |
Re: [Help-bash] How to catch errors in "readarray ... < <(...)" |
Date: |
Fri, 27 Mar 2015 13:51:02 +0200 |
On Thu, Mar 26, 2015 at 8:14 PM, Chet Ramey <address@hidden> wrote:
> On 3/26/15 11:55 AM, Peng Yu wrote:
> > Hi,
> >
> > The error in <() is not cached in the following code. Is there a
> > solution to this problem? Thanks.
> >
> > readarray -t array < <(printf '%s\n' 'a b' 'c d'; exit 1)
> > printf "%s\n" "address@hidden"
>
> You asked the exact same question less than three weeks ago in
> bug-bash.
>
> http://lists.gnu.org/archive/html/bug-bash/2015-03/msg00063.html
>
> Some of those suggestions may still be useful.
>
> http://lists.gnu.org/archive/html/bug-bash/2015-03/msg00066.html
> and
> http://lists.gnu.org/archive/html/bug-bash/2015-03/msg00100.html
>
> suggest possible approaches.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU address@hidden
> http://cnswww.cns.cwru.edu/~chet/
>
>
Note that you can even use PIPESTATUS in a script with a recent enough bash:
shopt -s lastpipe
command | readarray -t array;echo "${PIPESTATUS[0]}"