From 6230e82d44da25773437c5438c83a5d5fe275420 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 27 Sep 2017 09:41:50 +0100 Subject: 41764 (test tweaked): allow [key]+=value when modifying arrays --- Test/D04parameter.ztst | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'Test') diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index abac8f7a0..d6ed6487b 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -2302,3 +2302,37 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888 >KVA2two >KVA3three >* + + local -a keyvalarray + keyvalarray=(1 2 3) + keyvalarray+=([1]+=a [2]=b) + print $keyvalarray +0:Append to element(s) of array +>1a b 3 + + local -A keyvalhash + keyvalhash=([a]=a [b]=b [c]=c) + keyvalhash+=([a]+=yee [b]=ee) + local key val + for key in "${(ok)keyvalhash[@]}"; do + val=${keyvalhash[$key]} + print -r -- $key $val + done +0:Append to element(s) of associative array +>a ayee +>b ee +>c c + + local -a keyvalarray + keyvalarray=([1]=who [2]=anyway [1]+=is [1]+=that [1]+=mysterious [1]+=man) + print -rl -- "${keyvalarray[@]}" +0:Append to element of associative array on creation +>whoisthatmysteriousman +>anyway + + local -A keyvalhash + keyvalhash=([one]=hows [one]+=your [one]+=father [one]+=today) + print -rl -- ${(kv)keyvalhash} +0:Append to element of associative array on creation +>one +>howsyourfathertoday -- cgit 1.4.1