> On Jul 22, 2020, at 4:12 AM, andrej--- via Bug reports for the GNU
> Bourne Again SHell <[email protected]> wrote:
>
> Description:
> Integer variables don't get (re)parsed when (re)declared.
>
> Repeat-By:
> a=z
> declare -i a
> echo $a # z (I'd expect emptiness or 0)
The man page explicitly says that arithmetic evaluation is performed
*on assignment*.
-i The variable is treated as an integer; arithmetic evaluation
(see ARITHMETIC EVALUATION above) is performed when the
variable is assigned a value.
Sure enough:
% bash
bash-5.0$ a=z
bash-5.0$ declare -i a
bash-5.0$ echo "$a"
z
bash-5.0$ a=z
bash-5.0$ echo "$a"
0
vq