Re: Undocumented for-loop construct

2020-08-06 Thread Lawrence Velázquez
> On Aug 6, 2020, at 10:29 PM, Dale R. Worley wrote: > > Klaas Vantournhout writes: >> Recently I came across a surprising undocumented bash-feature >> >> $ for i in 1 2 3; { echo $i; }; >> >> The usage of curly-braces instead of the well-documented do ... done >> construct was a complete

Re: Undocumented for-loop construct

2020-08-06 Thread Dale R. Worley
Klaas Vantournhout writes: > Recently I came across a surprising undocumented bash-feature > >$ for i in 1 2 3; { echo $i; }; > > The usage of curly-braces instead of the well-documented do ... done > construct was a complete surprise to me and even lead me to open the > following question on

Undocumented for-loop construct

2020-08-06 Thread Klaas Vantournhout
Dear Bash-developers, Recently I came across a surprising undocumented bash-feature $ for i in 1 2 3; { echo $i; }; The usage of curly-braces instead of the well-documented do ... done construct was a complete surprise to me and even lead me to open the following question on stack overflow:

Re: Is this a bug?

2020-08-06 Thread Valentin Bajrami
Are you trying to run autocompletion on an nfs mount? Are you using ''ls'' to autocomplete and if so did you run \ls /path/to/dir .. ? Maybe worth to mention the bash version you are using. Op do 6 aug. 2020 19:53 schreef George R Goffe : > Hi, > > I apologize for bothering you with this

Re: Is this a bug?

2020-08-06 Thread Chet Ramey
On 8/6/20 1:53 PM, George R Goffe wrote: > Hi, > > I apologize for bothering you with this question. > > I have several directories on a system with > 300k files. When I use filename > completion bash freezes for over a minute depending on the number of files. > I'm pretty sure that bash has

Re: Is this a bug?

2020-08-06 Thread Dmitry Goncharov via Bug reports for the GNU Bourne Again SHell
On Thu, Aug 6, 2020 at 1:54 PM George R Goffe wrote: > I have several directories on a system with > 300k files. When I use filename > completion bash freezes for over a minute depending on the number of files. > I'm pretty sure that bash has to read the directory to do the completion but >

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) >>>

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

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, > >

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

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 $! ||

Re: Expand first before asking the question "Display all xxx possibilities?"

2020-08-06 Thread Ilkka Virta
On 6.8. 15:59, Chet Ramey wrote: On 8/6/20 8:13 AM, Ilkka Virta wrote: I think they meant the case where all the files matching the given beginning have a longer prefix in common. The shell expands that prefix to the command line after asking to show all possibilities. Only if you set the

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

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;

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

Re: Expand first before asking the question "Display all xxx possibilities?"

2020-08-06 Thread Chet Ramey
On 8/6/20 8:13 AM, Ilkka Virta wrote: > On 5.8. 22:21, Chris Elvidge wrote: >> On 05/08/2020 02:55 pm, Chet Ramey wrote: >>> On 8/2/20 6:55 PM, 積丹尼 Dan Jacobson wrote: how about doing the expansion first, so entering $ zz /jidanni_backups/da would then change into >>  >> $ zz

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",

Re: Expand first before asking the question "Display all xxx possibilities?"

2020-08-06 Thread Davide Brini
On Thu, 6 Aug 2020 15:13:30 +0300, Ilkka Virta wrote: > I think they meant the case where all the files matching the given > beginning have a longer prefix in common. The shell expands that prefix > to the command line after asking to show all possibilities. > > $ rm * > $ touch

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

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: Expand first before asking the question "Display all xxx possibilities?"

2020-08-06 Thread Ilkka Virta
On 5.8. 22:21, Chris Elvidge wrote: On 05/08/2020 02:55 pm, Chet Ramey wrote: On 8/2/20 6:55 PM, 積丹尼 Dan Jacobson wrote: how about doing the expansion first, so entering $ zz /jidanni_backups/da would then change into >> $ zz /jidanni_backups/dan_home_bkp with below it the question >>

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