Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: What's the reasoning behind z & s returning nular for empty input?



On Sat, 9 Nov 2019 at 09:52, Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> On Sat, Nov 9, 2019 at 9:40 AM Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
> > Yes, I was also referring to this fragment, however it states that the
> > empty elements should be removed, and even – that they should be
> > removed more eagerly, so I still wonder why produce a nular for an
> > empty input?
>
> Oh, I see what you mean. Apparently, only inner empty elements are
> dropped by "${(s...)...}" while the first and the last are retained.
>
>     "${(s:,:):-a,,b}" => (a b)
>     "${(s:,:):-,,}" => ('' '')
>
> Looks like it's either a bug in the code or in the documentation.

True, I wasn't fully aware of that:

array=( "${(s:,:):-,,}" )
print -r ${(q)array}
Output:'' ''

array=( "${(s:,:):-,}" )
print -r ${(q)array}
Output:'' ''

I think that the documentation or the behavior should be updated.
-- 
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