[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare -F incorrect line number
From: |
Chet Ramey |
Subject: |
Re: declare -F incorrect line number |
Date: |
Sat, 8 Oct 2022 13:24:50 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 |
On 10/2/22 4:51 AM, Daniel Castro wrote:
Bash Version: 5.0
Patch Level: 17
Release Status: release
Description:
declare -F yields the wrong line number for a function that has
nested functions declared within. Instead it gives the line number of
the last nested function.
This is a consequence of using a bison-generated parser, which basically
makes you do things `bottom-up': you know you have a complete function
definition only when you have a complete function definition and the
production reduces. The lexer keeps track of what looks like the start of
a function definition, and if the parser ends up reducing the function def
rule, we can use it to set the line number the function starts on.
It's pretty easy to put something in to save the last value when you set
the start of a function definition, allowing us to save the line number
for one level of function nesting. Anything more than that requires some
sort of stack, and I'm not sure it's worth the implementation cost.
Chet
--
``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/
- declare -F incorrect line number, Daniel Castro, 2022/10/02
- Re: declare -F incorrect line number, Chet Ramey, 2022/10/05
- RE: declare -F incorrect line number, Daniel Castro, 2022/10/05
- Re: declare -F incorrect line number, Chet Ramey, 2022/10/05
- Re: declare -F incorrect line number, Robert Elz, 2022/10/05
- Re: declare -F incorrect line number, Chet Ramey, 2022/10/06
- Re: declare -F incorrect line number, Martin D Kealey, 2022/10/06
- Re: declare -F incorrect line number, Greg Wooledge, 2022/10/06
- Re: declare -F incorrect line number, Martin D Kealey, 2022/10/11
Re: declare -F incorrect line number,
Chet Ramey <=