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, 2019-11-09 at 09:22 +0100, Roman Perepelitsa wrote:
> On Sat, Nov 9, 2019 at 9:11 AM Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
> > 
> > Thanks for the analysis. The additional problem is that quoted but
> > @-lacking s-flag should still elide the empty elements, as the manual
> > states. So this is an intentional exception and I wonder why it has
> > been added?
> Here's the passage from zshexpn:
>     For historical reasons, the usual behaviour that empty array
>     elements are retained inside double quotes is disabled for arrays
>     generated by splitting; hence the following:
>         line="one::three"
>         print -l "${(s.:.)line}"
>     produces two lines of output for one and three and elides the
>     empty field. To override this behaviour, supply the ‘(@)’ flag as
>     well, i.e. "${(@s.:.)line}".
> The phrase "for history reasons" is used to describe past design
> decisions and/or implementations that would be different if the
> benefit of hindsight were available at the time, but changing which is
> infeasible due to the existing code relying on the current behavior.
> In other words, the current behavior is unfortunate but cannot be
> changed.

This doesn't really help, but this would certainly be one of the first
"features" out of the window if we were starting from scratch...


Messages sorted by: Reverse Date, Date, Thread, Author