Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Filtering array on index
On Tue, 23 Jul 2019 at 09:42, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
> I wonder what's going on? The code looks OK. Maybe it's a bug?
So it seems that the ++idx within the ::=-treated array brackets is
executed twice. This might get considered a bug, but there's a chance
that this is how the code is arranged. After moving ++idx outside, the
code works:
% a=(-v filter1 -v filter2 )
% idx=0; olen=$#a+1; : ${a[@]/(#m)*/$((++idx))${a[idx]::=${a[idx % 2 ?
olen : idx]}}}
% print $a
filter1
filter2
Of course the empty elements are still there so an empty-element
eradicating use like above is needed.
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author