help-bash
[Top][All Lists]
Advanced

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

Re: reading from external command


From: Alex fxmbsw7 Ratchev
Subject: Re: reading from external command
Date: Thu, 31 Mar 2022 00:37:29 +0200

try, a second wait or wait -n
i suppose it may return the second return code

On Thu, Mar 31, 2022 at 12:33 AM Peng Yu <pengyu.ut@gmail.com> wrote:

> I am not sure how wait for "$!" would work robustly.
>
> In the following example, it can not get the error in the input.
>
> $ cat ./main.sh
> #!/usr/bin/env bash
> # vim: set noexpandtab tabstop=2:
>
> while read -r x; do
>         echo <(exit 42)
> done < <(
>         builtin printf '%s\n' a b c
>         false
> )
> wait "$!"
> echo "$?"
> $ ./main.sh
> /dev/fd/63
> /dev/fd/63
> /dev/fd/63
> 42
>
> On 3/30/22, Chet Ramey <chet.ramey@case.edu> wrote:
> > On 3/30/22 1:44 PM, Peng Yu wrote:
> >> I don't get what you mean. Could you elaborate on it? Thanks.
> >
> > The PID of the most recent process substitution is available in $!, like
> > any other asynchronous process. You can wait on that.
> >
> >
> > --
> > ``The lyf so short, the craft so long to lerne.'' - Chaucer
> >                ``Ars longa, vita brevis'' - Hippocrates
> > Chet Ramey, UTech, CWRU    chet@case.edu
> http://tiswww.cwru.edu/~chet/
> >
>
>
> --
> Regards,
> Peng
>
>


reply via email to

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