Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Empty element elision and associative arrays (was Re: Slurping a file)
On Fri, Jan 19, 2024 at 9:15 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> ... so however much I think there should be a defined order to the way the arrays print, it seems easy enough to use other tools to do it.
% typeset -A foo=( [zero]=0 [one]=1 [two]=2 [three]=3 [four]=4 )
% foo[other]='some random $text here'
% foo[nil]=''
% print -raC2 -- ${(z)${(*ok)foo/(#b)(*)/${(q)match[1]} ${(q-)foo[$match[1]]}}}
four 4
nil ''
one 1
other 'some random $text here'
three 3
two 2
zero 0
(the * in (*ok) requires zsh 5.9, otherwise setopt extendedglob)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author