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: Martin D Kealey
Subject: Re: integer variable that unsets itself causes segfault
Date: Sat, 16 Aug 2025 19:59:45 +1000

Hi Chet

On Tue, 12 Aug 2025 at 01:18, Chet Ramey <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.

I would rather that assignment modifier flags (-i, -l, -u, -r} simply be
ignored when binding.
Then it's a choice between:
 (a) applying those flags to the variable that it's bound to, or
 (b) enforcing them when indirectly assigning to a target variable.

Since we can already  write « declare -i "$reference" », I think (b) would
be more useful, and less surprising.

Assuming (b) then I would expect an error if «-n» is combined with «-f»,
«-F» or «-x».

Is it worth my while to attempt a patch to implement this?

-Martin


reply via email to

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