bug-bash
[Top][All Lists]
Advanced

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

Re: integer variable that unsets itself causes segfault


From: Chet Ramey
Subject: Re: integer variable that unsets itself causes segfault
Date: Tue, 19 Aug 2025 10:15:56 -0400
User-agent: Mozilla Thunderbird

On 8/16/25 5:59 AM, Martin D Kealey wrote:
Hi Chet

On Tue, 12 Aug 2025 at 01:18, Chet Ramey <chet.ramey@case.edu <mailto:chet.ramey@case.edu>> wrote:

    On 8/9/25 1:09 AM, Oğuz wrote:
     >      $ declare -in x=a[x]
     >      $ echo $?
     >      1
     >      $ declare -p x
     >      bash: declare: x: not found

    Since you have -i, the a[x] expands to `0', which is an invalid name for
a nameref, resulting in an assignment error.

That's … a surprising explanation, especially given that it /looks/ like infinite recursion.

No different than evaluating a variable value in an expression as an
expression.

I would rather that assignment modifier flags (-i, -l, -u, -r} simply be ignored when binding.

I'm sure you would, but that's neither backwards compatible nor compatible
with other shells (ksh93, mksh, even zsh) that impletment declare/typeset.

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



reply via email to

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