Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread Greg Wooledge
On Tue, Oct 17, 2023 at 04:46:22AM +0200, Christoph Anton Mitterer wrote: > But why does it even try to evaluate the subscript "key" as arithmetic > expression? Because that's how indexed arrays work. Everything inside the square brackets is an arithmetic expression, and in an arithmetic context,

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread Zachary Santer
On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote: > unicorn:~$ unset -v a b c array > unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array > declare -a array=([42]="foo") > What? What is Bash doing here? Dereferencing iteratively until it finds something it can do arithmetic with

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread Zachary Santer
On Tue, Oct 17, 2023 at 8:43 AM Zachary Santer wrote: > On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote: > >> unicorn:~$ unset -v a b c array >> unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array >> declare -a array=([42]="foo") >> > What? What is Bash doing here? Dereferenci

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread alex xmb sw ratchev
On Tue, Oct 17, 2023, 15:09 Zachary Santer wrote: > On Tue, Oct 17, 2023 at 8:43 AM Zachary Santer wrote: > > > On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote: > > > >> unicorn:~$ unset -v a b c array > >> unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array > >> declare -a a

Re: Handling of SIGHUP

2023-10-17 Thread Chet Ramey
On 10/15/23 10:29 PM, Dale R. Worley wrote: The basic explanation of how Bash handles SIGUP is (in 5.1): The shell exits by default upon receipt of a SIGHUP. Before exiting, an interactive shell resends the SIGHUP to all jobs, running or stopped. Stopped jobs

Re: value of $? and exit status are partially undocumented, possibly wrong

2023-10-17 Thread Chet Ramey
On 10/13/23 9:18 AM, Vincent Lefevre wrote: With bash 5.2.15(1)-release under Debian (bash 5.2.15-2+b6 package), on one of my machines: $ bash -c 'echo $?' 0 $ bash vlefevre@cventin:~$ echo $? 0 $ bash ; echo $? vlefevre@cventin:~$ exit exit 0 and on another one: $ bash -c 'echo $?' 0 $ bas

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread Chet Ramey
On 10/17/23 8:43 AM, Zachary Santer wrote: On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote: unicorn:~$ unset -v a b c array unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array declare -a array=([42]="foo") What? What is Bash doing here? Dereferencing iteratively until i

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread alex xmb sw ratchev
On Tue, Oct 17, 2023, 16:30 Chet Ramey wrote: > On 10/17/23 8:43 AM, Zachary Santer wrote: > > On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote: > > > >> unicorn:~$ unset -v a b c array > >> unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array > >> declare -a array=([42]="foo

Re: "read -s -n999 -t0.01 key" hangs until keypress

2023-10-17 Thread Chet Ramey
On 10/12/23 6:18 AM, Bodo Thiesen wrote: Hello list. The following script can be used to reproduce the problem. It seems to be related to sub-processes terminating at the "wrong" moment. The symptom: The script runs for some time counting up until at some moment the script hangs in the read func

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread Christoph Anton Mitterer
On Tue, 2023-10-17 at 00:26 -0400, Grisha Levit wrote: > The array subscript can an arbitrary arithmetic expression with side > effects, so it makes sense to perform the expansion even if the array > whose subscript is being expanded is unset: Okay... that's all pretty convoluted. I assume it boil

Re: "read -s -n999 -t0.01 key" hangs until keypress

2023-10-17 Thread Koichi Murase
2023年10月12日(木) 19:18 Bodo Thiesen : > Tested versions: > bash-5.1.16 with readline 8.1.2 > bash-5.2.15 with readline 8.2.1 You are using Bash 5.1, but I think it should have been already fixed in Bash 5.2. There were similar reports [1-3] (you may compare the test cases found there

Re: "read -s -n999 -t0.01 key" hangs until keypress

2023-10-17 Thread Chet Ramey
> 2023年10月12日(木) 19:18 Bodo Thiesen : > > Tested versions: > > bash-5.1.16 with readline 8.1.2 > > bash-5.2.15 with readline 8.2.1 > > You are using Bash 5.1, but I think it should have been already fixed > in Bash 5.2. There were similar reports [1-3] (you may compare the

Re: "read -s -n999 -t0.01 key" hangs until keypress

2023-10-17 Thread Koichi Murase
2023年10月18日(水) 0:01 Chet Ramey : > He claims to have tested on bash-5.2. I just can't reproduce it. Oh..., I somehow thought they were both 5.1 (5.1.16 and 5.1.15). I didn't notice my misreading even when I extracted the quoted part. Thanks for pointing it out. -- Koichi

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread Lawrence Velázquez
On Tue, Oct 17, 2023, at 10:48 AM, Christoph Anton Mitterer wrote: > As Lawrence pointed out: > $ set -u > $ declare -A a > $ echo ${a[k]} > bash: a[k]: unbound variable > > Here it actually looks first at a (which turns out to be an associative > array) and thus doesn't even bother to evaluate k,

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread Grisha Levit
On Tue, Oct 17, 2023, 10:48 Christoph Anton Mitterer wrote: > > On Tue, 2023-10-17 at 00:26 -0400, Grisha Levit wrote: > > The array subscript can an arbitrary arithmetic expression with side > > effects, so it makes sense to perform the expansion even if the array > > whose subscript is being exp

Re: "read -s -n999 -t0.01 key" hangs until keypress

2023-10-17 Thread Bodo Thiesen
* Koichi Murase hat geschrieben: > 2023年10月18日(水) 0:01 Chet Ramey : >> He claims to have tested on bash-5.2. I just can't reproduce it. > Oh..., I somehow thought they were both 5.1 (5.1.16 and 5.1.15). I > didn't notice my misreading even when I extracted the quoted part. > Thanks for pointing i

Re: "read -s -n999 -t0.01 key" hangs until keypress

2023-10-17 Thread Chet Ramey
On 10/17/23 4:29 PM, Bodo Thiesen wrote: * Koichi Murase hat geschrieben: 2023年10月18日(水) 0:01 Chet Ramey : He claims to have tested on bash-5.2. I just can't reproduce it. Oh..., I somehow thought they were both 5.1 (5.1.16 and 5.1.15). I didn't notice my misreading even when I extracted the

Re: bash tries to parse comsub in quoted PE pattern

2023-10-17 Thread Emanuele Torre
> braces.c > - brace_gobbler: use extract_dollar_brace_string if we see ${ with > the appropriate value of QUOTING, so we don't have to teach brace > expansion more shell syntax. > Report from Emanuele Torre > - brace_gobbler: call the word extraction functions

Re: value of $? and exit status are partially undocumented, possibly wrong

2023-10-17 Thread Vincent Lefevre
On 2023-10-17 10:16:35 -0400, Chet Ramey wrote: > On 10/13/23 9:18 AM, Vincent Lefevre wrote: > > The difference seems to be due to the exit status of the last command > > of the .bashrc file. But this is undocumented. > > How so? The exit status ($?) is the status of "the last command executed,"