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    c...@case.edu    http://tiswww.cwru.edu/~chet/


Reply via email to