Re: integer variable that unsets itself causes segfault
From:
Zachary Santer
Subject:
Re: integer variable that unsets itself causes segfault
Date:
Sat, 30 Aug 2025 12:22:40 -0400
On Sat, Aug 30, 2025 at 11:41 AM Chet Ramey <chet.ramey@case.edu> wrote:
>
> It occurs to me that bash should print a warning when you attempt something
> like this:
>
> declare -n foo=bar
> declare -i foo
>
> since bash disallows that now by ignoring the attempt to add the integer
> attribute
The manual explicitly lays this out as something you can do:
-n Give each name the nameref attribute, making it a name reference
to another variable. That other variable is defined by the value of
name. All references, assignments, and attribute modifications to
name, except those using or changing the -n attribute itself, are
performed on the variable referenced by name's value. The nameref
attribute cannot be applied to array variables.
It results in
$ declare -p foo bar
declare -n foo="bar"
declare -i bar