[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:54:35 +0200 |
On Thu, Mar 31, 2022 at 12:45 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
wrote:
>
> ill try
>
> On Thu, Mar 31, 2022, 00:44 Peng Yu <pengyu.ut@gmail.com> wrote:
>>
>> I am not sure exactly what I should use. I can not get it to work.
>> Would you please write down the complete code to demonstrate what you
>> mean?
i sadly cant, i assumed what isnt
it seems wait needs a pid to return its status code
i mean wait alone returns 0
wait -n returns 127
only wait $! did somewhat of that code passing
but as i dont know a $PIDSTATUS .. ..
sorry was misinformation, like many times by me
>>
>> $ ./main2.sh
>> /dev/fd/63
>> /dev/fd/63
>> /dev/fd/63
>> 42
>> 127
>> $ cat ./main2.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 "$?"
>> wait -n
>> echo "$?"
>>
>> $ ./main3.sh
>> /dev/fd/63
>> /dev/fd/63
>> /dev/fd/63
>> 42
>> 0
>> $ cat main3.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 "$?"
>> wait
>> echo "$?"
>>
>> On 3/30/22, Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
>> > 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
>> >>
>> >>
>> >
>>
>>
>> --
>> Regards,
>> Peng
- Re: reading from external command, (continued)
- Re: reading from external command, Lawrence Velázquez, 2022/03/30
- Re: reading from external command, Alex fxmbsw7 Ratchev, 2022/03/30
- Re: reading from external command, Peng Yu, 2022/03/30
- Re: reading from external command, Alex fxmbsw7 Ratchev, 2022/03/30
- Re: reading from external command, Alex fxmbsw7 Ratchev, 2022/03/31
- Re: reading from external command, Alex fxmbsw7 Ratchev, 2022/03/31
- Re: reading from external command, Chet Ramey, 2022/03/31
- Re: reading from external command, Peng Yu, 2022/03/31
- Re: reading from external command, Alex fxmbsw7 Ratchev, 2022/03/31
- Re: reading from external command, Alex fxmbsw7 Ratchev, 2022/03/31