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

Re: PATCH: bug in ${(z)...} with newlines



On Wed, 9 Jun 2010 07:34:47 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Wed, Jun 9, 2010 at 6:07 AM, Peter Stephenson <pws@xxxxxxx> wrote:
> > This must be a bug, mustn't it?
> >
> > % foo=$'one\ntwo'
> > % print ${(z)foo}
> > one ; two
> 
> I'm pretty sure that's intentional, so that when the newline is
> removed by splitting, the join is still a semantically equivalent
> shell expression.  Otherwise you can't do stuff like this:
>...
> > As far as splitting arguments goes, the newline is just whitespace.
> 
> Yes, but (z) is really for parsing, not merely splitting.

Hmm.  I've only ever used (z) for splitting words (which is why it was 'z',
since 's' was used), which is my memory of why it was introduced.  Now
you're telling me it's for something other than what it says in the manual,
which just says parsing is to find the words, and I can't use it without
jumping through hoops.  Nor can I think of a case where I would use it to
find lines of code.

I can certainly believe the completion system, which uses the same code
underneath, might be relying on undocumented 'intentional' features.

-- 
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