Re: Incorrect LINENO with exported nested functions with loops

2021-10-10 Thread Chet Ramey
On 10/9/21 3:47 PM, Chet Ramey wrote: The FOR token is what causes the parser to increment word_top. The ARITH_FOR_EXPRS token parses just one part of that production (the ((...;...;...)) part). It's true that the function that parses the stuff between the double parens doesn't use word_lineno[w

Re: Incorrect LINENO with exported nested functions with loops

2021-10-09 Thread Chet Ramey
On 10/7/21 5:06 PM, Tom Coleman wrote: You are correct that FOR loops increment the word_top variable in the read_token_word function, but, ARITH_FOR_EXPRS loops do not. They are treated separately and do not increment the word_top variable from what I can see. #define FOR 265 #define ARITH_F

Re: Incorrect LINENO with exported nested functions with loops

2021-10-07 Thread Tom Coleman
You are correct that FOR loops increment the word_top variable in the read_token_word function, but, ARITH_FOR_EXPRS loops do not. They are treated separately and do not increment the word_top variable from what I can see. #define FOR 265 #define ARITH_FOR_EXPRS 286 On Fri, Oct 8, 2021 at 7:10

Re: Incorrect LINENO with exported nested functions with loops

2021-10-07 Thread Chet Ramey
On 10/7/21 12:58 AM, Tom Coleman wrote: > I did some experimenting and am confident on the fix. I don't know how to > supply a patch suggestion officially, but have pasted it below. Four lines > in parse.y need deleting. Arithmetic for loops should NOT be decrementing > the 'word_top' variable, the

Re: Incorrect LINENO with exported nested functions with loops

2021-10-06 Thread Tom Coleman
I did some experimenting and am confident on the fix. I don't know how to supply a patch suggestion officially, but have pasted it below. Four lines in parse.y need deleting. Arithmetic for loops should NOT be decrementing the 'word_top' variable, they do not make use of it. This also has flow on t

Re: Incorrect LINENO with exported nested functions with loops

2021-10-06 Thread Tom Coleman
I was actually incorrect about something in here. Initially I discovered the bug when this was in two scripts. I've discovered that it is actually much simpler and nothing to do with exporting functions. Updated script is below. >From examination I've done to date, using BASH 5.1.8, each function

Re: Incorrect LINENO with exported nested functions with loops

2021-10-06 Thread L A Walsh
On 2021/10/05 16:25, Tom Coleman wrote Repeat-By: Below is a sample script to replicate the bug in LINENO. --- 1st prob: scrip doesn't work as is. /tmp/lnno /tmp/lnno: line 23: syntax error near unexpected token `done' /tmp/lnno: line 23: ` done' added the line numbers inde

Incorrect LINENO with exported nested functions with loops

2021-10-05 Thread Tom Coleman
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -