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 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.

Thanks for the report.

This changed between bash-4.2 and bash-4.3 as part of changes to avoid
scanning the subscript in an associative array reference multiple times:
before and after expansion, and for compatibility with ksh93 (which
behaves the same as bash-4.3+).

It's obliquely referenced in the documentation:

"When  +=  is  applied  to an array variable using compound
 assignment (see Arrays below), the variable's value is not unset (as it
 is when using =)"

However, I agree that it would be more consistent to let the expansion
of the rhs use the existing value of the array before clearing it, since
that's what indexed arrays do. I'll make associative array assignment
do that.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to