Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${(q)...} for newline
- X-seq: zsh-workers 27974
- From: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: ${(q)...} for newline
- Date: Tue, 25 May 2010 15:48:24 +0100
- In-reply-to: <chaz20100525132513.GB4384@xxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Cambridge Silicon Radio
- References: <p.w.stephenson@xxxxxxxxxxxx> <10739.1274644720@pws-pc> <201005232045.o4NKjdLO027329@xxxxxxxxxxxxxxxxxxx> <chaz20100525132513.GB4384@xxxxxxxx>
On Tue, 25 May 2010 14:25:13 +0100
Stephane Chazelas <stephane_chazelas@xxxxxxxx> wrote:
> 2010-05-23 21:45:39 +0100, Peter Stephenson:
> > Also, would I be right in thinking this is an accident waiting to
> > happen?
> >
> > % foo=(one '' three)
> > % print ${(q)foo}
> > one three
>
> Not in the first case though, as array expansion removes the
> empty elements.
I don't think that argument really works... consider:
% foo=(one '' three)
% print ${(j.X.)foo}
oneXXthree
In other words, flags are applied before empty elements are
stripped. The same goes for most transformations on array elements,
whether zsh-specific or otherwise; I don't see why (q) should be
different.
However, we don't actually say in the (already long) manual entry giving
the rules for variable expansion at what part either quoting or empty
element removal takes place. The latter appears to be the last thing of all,
i.e. at the point where we decide to insert this into the list of arguments
(or otherwise). I should probably concoct something.
Bart wrote
> However, I suggest that (q-) continue to use the literal quoted newline.
Right, it's really there as minimal quoting for human readability.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author