Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: treatment of empty strings - why is this not a bug?
- X-seq: zsh-workers 26306
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh list <zsh-workers@xxxxxxxxxx>
- Subject: Re: treatment of empty strings - why is this not a bug?
- Date: Tue, 13 Jan 2009 22:08:10 +0000
- In-reply-to: <20090113192409.0c21909a@pws-pc>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <18796.17298.94642.461735@xxxxxxxxxxxxxxxxxx> <20090113192409.0c21909a@pws-pc>
On Tue, 13 Jan 2009 19:24:09 +0000
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Tue, 13 Jan 2009 02:32:34 -0500
> Greg Klanderman <gak@xxxxxxxxxxxxxx> wrote:
> > lwm% x=::: && for v in "${(s-:-)x}" ; do echo "v= =>$v<=" ; done
> > v= =><=
> > v= =><=
>
> Hmm...
>
> % setopt rcexpandparam
> % x=::: && for v in "${(s-:-)x}" ; do echo "v= =>$v<=" ; done
> v= =><=
> v= =><=
> v= =><=
> v= =><=
>
> What's this got to do with RC_EXPAND_PARAM and why is the behaviour
> without that option not a bug? Er... I'm very glad you asked.
>
> --
> Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
> Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Oh, yes. I had to look at the code before the answer came to me,
again---I've run up against this one several times before.
It's not a bug because it's documented to do something incredibly
pointless:
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:
example(line="one::three"
print -l "${(s.:.)line}")
produces two lines of output for tt(one) and tt(three) and elides the
empty field. To override this behaviour, supply the "(@)" flag as well,
i.e. tt("${(@s.:.)line}").
Not sure why RC_EXPAND_PARAM makes it work more sensibly, however.
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author