Re: process substitution error handling

2020-08-06 Thread Eli Schwartz
On 8/6/20 12:36 PM, k...@plushkava.net wrote: > On 06/08/2020 17:21, Eli Schwartz wrote: >> On 8/6/20 11:31 AM, Jason A. Donenfeld wrote: >>> That doesn't always work: >>> >>> set -e >>> while read -r line; do >>>     echo "$line" & >>> done < <(echo 1; sleep 1; echo 2; sleep 1; exit 77) >>> sl

Re: process substitution error handling

2020-08-06 Thread
On 06/08/2020 17:21, Eli Schwartz wrote: On 8/6/20 11:31 AM, Jason A. Donenfeld wrote: That doesn't always work: set -e while read -r line; do echo "$line" & done < <(echo 1; sleep 1; echo 2; sleep 1; exit 77) sleep 1 wait $! echo done I wonder why wait $! doesn't do the job here.

Re: process substitution error handling

2020-08-06 Thread Eli Schwartz
On 8/6/20 11:31 AM, Jason A. Donenfeld wrote: > That doesn't always work: > > set -e > while read -r line; do >echo "$line" & > done < <(echo 1; sleep 1; echo 2; sleep 1; exit 77) > sleep 1 > wait $! > echo done So instead of your contrived case, write it properly. Check the process subst

Re: process substitution error handling

2020-08-06 Thread Chet Ramey
On 8/6/20 11:31 AM, Jason A. Donenfeld wrote: > On Thu, Aug 6, 2020 at 4:49 PM Chet Ramey wrote: >> >> On 8/6/20 10:36 AM, Jason A. Donenfeld wrote: >>> Hi Chet, >>> >>> On Thu, Aug 6, 2020 at 4:30 PM Chet Ramey wrote: On 8/6/20 6:05 AM, Jason A. Donenfeld wrote: > Hi, > > I

Re: process substitution error handling

2020-08-06 Thread Jason A. Donenfeld
On Thu, Aug 6, 2020 at 4:49 PM Chet Ramey wrote: > > On 8/6/20 10:36 AM, Jason A. Donenfeld wrote: > > Hi Chet, > > > > On Thu, Aug 6, 2020 at 4:30 PM Chet Ramey wrote: > >> > >> On 8/6/20 6:05 AM, Jason A. Donenfeld wrote: > >>> Hi, > >>> > >>> It may be a surprise to some that this code here wi

Re: process substitution error handling

2020-08-06 Thread Chet Ramey
On 8/6/20 10:48 AM, Chet Ramey wrote: >> Perhaps another, clunkier, proposal would be to add `wait -s` so that >> the wait builtin also waits for process substitutions and returns >> their exit codes and changes $?. The downside would be that scripts >> now need to add a "wait" after all of above

Re: process substitution error handling

2020-08-06 Thread Chet Ramey
On 8/6/20 10:36 AM, Jason A. Donenfeld wrote: > Hi Chet, > > On Thu, Aug 6, 2020 at 4:30 PM Chet Ramey wrote: >> >> On 8/6/20 6:05 AM, Jason A. Donenfeld wrote: >>> Hi, >>> >>> It may be a surprise to some that this code here winds up printing >>> "done", always: >>> >>> $ cat a.bash >>> set -e -

Re: process substitution error handling

2020-08-06 Thread Jason A. Donenfeld
Hi Chet, On Thu, Aug 6, 2020 at 4:30 PM Chet Ramey wrote: > > On 8/6/20 6:05 AM, Jason A. Donenfeld wrote: > > Hi, > > > > It may be a surprise to some that this code here winds up printing > > "done", always: > > > > $ cat a.bash > > set -e -o pipefail > > while read -r line; do > >echo

Re: process substitution error handling

2020-08-06 Thread Chet Ramey
On 8/6/20 6:05 AM, Jason A. Donenfeld wrote: > Hi, > > It may be a surprise to some that this code here winds up printing > "done", always: > > $ cat a.bash > set -e -o pipefail > while read -r line; do >echo "$line" > done < <(echo 1; sleep 1; echo 2; sleep 1; false; exit 1) > sleep 1 >

Re: process substitution error handling

2020-08-06 Thread
On 06/08/2020 14:57, Eli Schwartz wrote: On 8/6/20 9:15 AM, k...@plushkava.net wrote: You beat me to it. I was just about to suggest wait $! || exit. Indeed, I mentioned the same in a recent bug report against wireguard-tools. So if I understand correctly, you reported the lack of wait $! || e

Re: process substitution error handling

2020-08-06 Thread Eli Schwartz
On 8/6/20 9:15 AM, k...@plushkava.net wrote: > You beat me to it. I was just about to suggest wait $! || exit. Indeed, > I mentioned the same in a recent bug report against wireguard-tools. So if I understand correctly, you reported the lack of wait $! || exit in a script, and the script author in

Re: process substitution error handling

2020-08-06 Thread
On 06/08/2020 13:33, Eli Schwartz wrote: On 8/6/20 6:05 AM, Jason A. Donenfeld wrote: Hi, It may be a surprise to some that this code here winds up printing "done", always: $ cat a.bash set -e -o pipefail while read -r line; do echo "$line" done < <(echo 1; sleep 1; echo 2; sleep 1; fa

Re: process substitution error handling

2020-08-06 Thread Oğuz
6 Ağustos 2020 Perşembe tarihinde Greg Wooledge yazdı: > On Thu, Aug 06, 2020 at 02:14:07PM +0200, Jason A. Donenfeld wrote: > > On Thu, Aug 6, 2020 at 1:15 PM Oğuz wrote: > > > set -e o substfail > > > : <(sleep 10; exit 1) > > > foo > > > > > > Say that `foo' is a command that take

Re: process substitution error handling

2020-08-06 Thread Eli Schwartz
On 8/6/20 6:05 AM, Jason A. Donenfeld wrote: > Hi, > > It may be a surprise to some that this code here winds up printing > "done", always: > > $ cat a.bash > set -e -o pipefail > while read -r line; do >echo "$line" > done < <(echo 1; sleep 1; echo 2; sleep 1; false; exit 1) > sleep 1 >

Re: process substitution error handling

2020-08-06 Thread Jason A. Donenfeld
On Thu, Aug 6, 2020 at 2:14 PM Jason A. Donenfeld wrote: > > On Thu, Aug 6, 2020 at 1:15 PM Oğuz wrote: > > > > > > > > 6 Ağustos 2020 Perşembe tarihinde Jason A. Donenfeld > > yazdı: > >> > >> Hi, > >> > >> It may be a surprise to some that this code here winds up printing > >> "done", always:

Re: process substitution error handling

2020-08-06 Thread Greg Wooledge
On Thu, Aug 06, 2020 at 02:14:07PM +0200, Jason A. Donenfeld wrote: > On Thu, Aug 6, 2020 at 1:15 PM Oğuz wrote: > > set -e o substfail > > : <(sleep 10; exit 1) > > foo > > > > Say that `foo' is a command that takes longer than ten seconds to complete, > > how would you expect the sh

Re: process substitution error handling

2020-08-06 Thread Jason A. Donenfeld
On Thu, Aug 6, 2020 at 1:15 PM Oğuz wrote: > > > > 6 Ağustos 2020 Perşembe tarihinde Jason A. Donenfeld yazdı: >> >> Hi, >> >> It may be a surprise to some that this code here winds up printing >> "done", always: >> >> $ cat a.bash >> set -e -o pipefail >> while read -r line; do >>echo "$

Re: process substitution error handling

2020-08-06 Thread Oğuz
6 Ağustos 2020 Perşembe tarihinde Jason A. Donenfeld yazdı: > Hi, > > It may be a surprise to some that this code here winds up printing > "done", always: > > $ cat a.bash > set -e -o pipefail > while read -r line; do >echo "$line" > done < <(echo 1; sleep 1; echo 2; sleep 1; false; exit

process substitution error handling

2020-08-06 Thread Jason A. Donenfeld
Hi, It may be a surprise to some that this code here winds up printing "done", always: $ cat a.bash set -e -o pipefail while read -r line; do echo "$line" done < <(echo 1; sleep 1; echo 2; sleep 1; false; exit 1) sleep 1 echo done $ bash a.bash 1 2 done The reason for this is that proces