On 3/29/21 6:40 PM, Eric Cook wrote:
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

OK, how would you do that? What construct would you use in this scenario?

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.

Wouldn't this be a programming error? If this were a concern, since any
array can have elements with empty values, I would recommend a different
strategy to copy it.

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