[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unexpected result of array assignment
From: |
Darren 'Tadgy' Austin |
Subject: |
Unexpected result of array assignment |
Date: |
Thu, 18 Jul 2019 02:16:41 +0100 |
User-agent: |
Alpine 2.21 (LNX 202 2017-01-01) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-LQgi2O/bash-5.0=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-Wno-parentheses -Wno-format-security
uname output: Linux phil 5.0.0-13-generic #14-Ubuntu SMP Mon Apr 15 14:59:14
UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.0
Patch Level: 3
Release Status: release
Description:
There seems to be unexpect (a bug?) behaviour with bash's handling of
array assignments.
Specifically, if you try to assign an array element a value containing
that same array value, it fails to work.
See example below :)
Bug confirmed by the folks in #bash on Freenode - unable to explain
what is happening.
Repeat-By:
declare -A foo
foo=(["key"]="value1")
declare -p foo
foo=(["key"]="${foo["key"]} value2")
declare -p foo
The above should result in 'foo["key"]' having a value of 'value1
value2', but the result is simply ' value2', which I believe to be incorrect
behaviour.
- Unexpected result of array assignment,
Darren 'Tadgy' Austin <=