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: Chet Ramey
Subject: Re: local -[aA] on dangling nameref
Date: Fri, 24 Oct 2025 12:26:28 -0400
User-agent: Mozilla Thunderbird

On 10/24/25 12:15 PM, Grisha Levit wrote:
On Fri, Oct 24, 2025, 09:04 Chet Ramey <chet.ramey@case.edu> wrote:

On 10/23/25 11:08 PM, Grisha Levit wrote:

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) )

Thanks for the report. I get

./x2: line 2: local: x: not found
./x2: line 3: warning: x: circular name reference
./x2: line 3: warning: x: circular name reference
declare -Ax x=()

with the latest devel branch, using interactive and non-interactive shells.

I'm also testing with commit 403b32fa.
Note that `x=x' is in the temporary environment of f.

./bash -c 'f() { local -n x; local -A x; local -p x; (local x=(z)); }; x=x f'

./bash: line 1: warning: x: circular name reference
./bash: line 1: warning: x: circular name reference
declare -Anx x=()
./bash: line 1: 10701 Segmentation fault ( local x=(z) )

I just freshly cloned the repository on macOS, switched to the devel
branch, built it and:

$ ./bash -c 'f() { local -n x; local -A x; local -p x; (local x=(z)); }; x=x f'
./bash: line 1: warning: x: circular name reference
./bash: line 1: warning: x: circular name reference
declare -Ax x=()


--
``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/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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