bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: local -[aA] on dangling nameref


From: Grisha Levit
Subject: Re: local -[aA] on dangling nameref
Date: Thu, 23 Oct 2025 23:08:55 -0400

On Mon, Oct 20, 2025, 11:36 Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 10/15/25 12:19 PM, Grisha Levit wrote:
> > While a compound assignment to a dangling nameref removes the
> > nameref attribute:
> >
> >      $ f() { local -n x; x=(); local -p; }; f
> >      bash: warning: x: removing nameref attribute
> >      declare -a x=()
> >
> > the same does not happen when using `local' to perform compound
> > assignment or to set the array or assoc attribute on a dangling
> > nameref:
>
> Thanks for the report. I don't get the segmentation fault, but converting
> an unset nameref into an array or an assoc variable should definitely
> remove the nameref attribute.

Looks like circular namerefs might need something similar as well:

    f() {
        local -n x; local -p x
        local -A x; local -p x
        (local x=(z))
    }
    x=x f

    bash: local: x: not found
    bash: warning: x: circular name reference
    bash: warning: x: circular name reference
    declare -Anx x=()
    Segmentation fault ( local x=(z) )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]