Re: Unexpected result of array assignment

2019-07-19 Thread Chet Ramey
On 7/17/19 9:16 PM, Darren 'Tadgy' Austin wrote: > 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 va

Re: Unexpected result of array assignment

2019-07-18 Thread Léa Gris
On 18/07/2019 14:12, Greg Wooledge wrote: On Thu, Jul 18, 2019 at 10:58:52AM +0200, Henning wrote: eval 'foo=(["key"]="'"${foo["key"]}"' value2")' If you just want to work around the bug, why not do it in the simplest way possible? foo["key"]+=" value2" Of co

Re: Unexpected result of array assignment

2019-07-18 Thread Henning
On 18/07/2019 14:12, Greg Wooledge wrote: On Thu, Jul 18, 2019 at 10:58:52AM +0200, Henning wrote: eval 'foo=(["key"]="'"${foo["key"]}"' value2")' If you just want to work around the bug, why not do it in the simplest way possible? foo["key"]+=" value2" Of course, you are right. H

Re: Unexpected result of array assignment

2019-07-18 Thread Henning
On 18/07/2019 11:19, Andreas Schwab wrote: On Jul 18 2019, Henning wrote: eval 'foo=(["key"]="'"${foo["key"]}"' value2")' This will break if ${foo["key"]} contains any of $ ` " \ . Correct. I'd only taken blanks into account. Henning

Re: Unexpected result of array assignment

2019-07-18 Thread Greg Wooledge
On Thu, Jul 18, 2019 at 10:58:52AM +0200, Henning wrote: > On 18/07/2019 03:16, Darren 'Tadgy' Austin wrote: > > > foo=(["key"]="${foo["key"]} value2") > > using eval shoud also succeed, even for older bash: > > eval 'foo=(["key"]="'"${foo["key"]}"' value2")' If you just want to

Re: Unexpected result of array assignment

2019-07-18 Thread Andreas Schwab
On Jul 18 2019, Henning wrote: > On 18/07/2019 03:16, Darren 'Tadgy' Austin wrote: > >> foo=(["key"]="${foo["key"]} value2") > > using eval shoud also succeed, even for older bash: > > eval 'foo=(["key"]="'"${foo["key"]}"' value2")' This will break if ${foo["key"]} contains any of

Re: Unexpected result of array assignment

2019-07-18 Thread Henning
On 18/07/2019 03:16, Darren 'Tadgy' Austin wrote: foo=(["key"]="${foo["key"]} value2") using eval shoud also succeed, even for older bash: eval 'foo=(["key"]="'"${foo["key"]}"' value2")' Henning

Re: Unexpected result of array assignment

2019-07-18 Thread Darren 'Tadgy' Austin
Hi, Thanks for the quick reply. :) [I tried to cc b...@tlinx.org on this email, but get a SERVFAIL from both DNS servers, so couldn't copy you in directly, sorry!] On Wed, 17 Jul 2019, L A Walsh wrote: > In bash4.4.12, Using: > I think you need to tell bask that you are updating 'foo' > instea

Re: Unexpected result of array assignment

2019-07-17 Thread L A Walsh
On 2019/07/17 18:16, Darren 'Tadgy' Austin wrote: > 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 >