|
From: | Eric Cook |
Subject: | Re: zsh style associative array assignment bug |
Date: | Mon, 29 Mar 2021 18:40:31 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 |
On 3/29/21 5:18 PM, Chet Ramey wrote:
If you look at a=( k1 v1 k2 v2 k3 v3) as more or less syntactic sugar for a=( [k1]=v1 [k2]=v2 [k3]=v3 ) it's reasonable that a=( k1 v1 k2 ) is equivalent to a=( [k1]=v1 [k2]= ). And that's what bash does.
Its just when populating that array dynamically with another array if that second array didn't contain `v1' hypothetically, the array gets shifted to a=( [k1]=k2 [v2]=k3 [v3]= ) which i would imagine to be unexpected for the author of the code and would rather it error out instead of chugging along.
[Prev in Thread] | Current Thread | [Next in Thread] |