diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2017-09-13 20:54:00 +0100 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2017-09-13 20:54:00 +0100 |
commit | 54b395844030342213cacba4c569a6c5e6781c46 (patch) | |
tree | b9de3dad4206d09d12c2b745e9bac6731d9bf221 /Test/B02typeset.ztst | |
parent | da4146bdffb54423ad4d6db893b8ed25663169dc (diff) | |
download | zsh-54b395844030342213cacba4c569a6c5e6781c46.tar.gz zsh-54b395844030342213cacba4c569a6c5e6781c46.tar.xz zsh-54b395844030342213cacba4c569a6c5e6781c46.zip |
First go at var=([key]=value) syntax.
Works for both normal and typeset case, also var+=... Still to do: allow to be mixed with straight array assignment, improve typeset -p, implement [key]+=value.
Diffstat (limited to 'Test/B02typeset.ztst')
-rw-r--r-- | Test/B02typeset.ztst | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index b27bb4f6b..ae218047c 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -721,3 +721,58 @@ # 'date' did not run. >Status is printed, 1 *?*: failed to change user ID: * + + typeset -A keyvalhash=([one]=eins [two]=zwei) + keyvalhash+=([three]=drei) + for key in ${(ok)keyvalhash}; do + print $key $keyvalhash[$key] + done +0:[key]=val for hashes +>one eins +>three drei +>two zwei + + local keyvalarray=([1]=one [3]=three) + print -l "${keyvalarray[@]}" + keyvalarray+=([2]=two) + print -l "${keyvalarray[@]}" + local keyvalarray=([1]=one [3]=three) + print -l "${keyvalarray[@]}" +0:[key]=val for normal arrays +>one +> +>three +>one +>two +>three +>one +> +>three + + touch foo Xnot_globbedX + inkey="another key" val="another value" + typeset -A keyvalhash=([$(echo the key)]=$(echo the value) + [$inkey]=$val + [*]=?not_globbed?) + for key in ${(ok)keyvalhash}; do + print -l $key $keyvalhash[$key] + done + typeset -A keyvalhash=([$(echo the key)]=$(echo the value) + [$inkey]=$val + [*]=?not_globbed?) + for key in ${(ok)keyvalhash}; do + print -l $key $keyvalhash[$key] + done +0:Substitution in [key]=val syntax +>* +>?not_globbed? +>another key +>another value +>the key +>the value +>* +>?not_globbed? +>another key +>another value +>the key +>the value |