Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Darren 'Tadgy' Austin Newsgroups: gnu.bash.bug Subject: Unexpected result of array assignment Date: Thu, 18 Jul 2019 02:16:41 +0100 Lines: 27 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: usenet.stanford.edu 1563426353 10561 209.51.188.17 (18 Jul 2019 05:05:53 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org User-Agent: Alpine 2.21 (LNX 202 2017-01-01) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 83.170.98.46 X-Mailman-Approved-At: Thu, 18 Jul 2019 01:05:52 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: Xref: csiph.com gnu.bash.bug:15184 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.