Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: field splitting with empty fields
- X-seq: zsh-users 12145
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: field splitting with empty fields
- Date: Tue, 30 Oct 2007 12:04:53 +0000
- In-reply-to: <20071030115827.GC5398@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20071029235835.GA29356@xxxxxxxxxxx> <071029171355.ZM28438@xxxxxxxxxxxxxxxxxxxxxx> <20071030042048.GA32506@xxxxxxxxxxx> <20071030104459.562a77b1@news01> <20071030115827.GC5398@xxxxxxxxxxxxxxx>
Stephane Chazelas wrote:
> > It's odd it removes the space even if quoted:
> >
> > % foo="one:two::four:five"
> > % print -l "${(@s.:.)foo}"
> > one
> > two
> > four
> > five
> [...]
>
> I've always known it to behave like that, I even thought it was
> documented but I can't find it now in the manual so maybe it
> wasn't.
>
> I've myself already relied on it before, though many other
> times, it's true I have wished it was not removing empty items.
The interesting question is: are there times when you need the double
quotes (for some other reason), but *still* don't want empty elements
removed? That would explain the kludge.
I certainly agree that
% print -l ${(s.:.)foo}
*should* remove empty elements.
We could in any case apply no-removal behaviour to the version with the
"@" flag (which we can detect even though it's not current having a
special effect in the expression at the top). That seems
unobjectionable, since the presence of the "@" specifies "$@"-like
behaviour. I'll do that if no one can see a further objection, though
it still leaves the kludge.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author