help-bash
[Top][All Lists]
Advanced

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

Re: reading from external command


From: Peng Yu
Subject: Re: reading from external command
Date: Wed, 30 Mar 2022 17:32:56 -0500

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]