Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Avoiding empty element when splitting NUL-separated string from command substitution
On Tue, 16 Aug 2011 13:51:38 +0100
Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Tue, 16 Aug 2011 14:13:58 +0200
> Nikolai Weibull <now@xxxxxxxx> wrote:
> > % b=(${(0)"$(print -n)"})
> > % echo $#b
> > 1
>
> I think that's a bug.
>
> The fix might be as simple as the following, but it probably needs a bit
> more investigation as to where the Nularg came from. If it was a
> nulstring, used in subst.c for reasons I can never remember (and, of
> course, aren't commented) this is fine; if it was something that should
> already have had remnulargs() applied to it the fix is somewhere else.
This is indeed a specially created null string propagating up from
readoutput() via multsub(), so I think the fix is legitimate. It's not
clear if sepsplit() should be using null strings in its output, however,
since I have no idea what they're for. That would be a different
pre-existing bug with different effects.
If you have any theories, you can post them to zsh-workers.
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.59
diff -p -u -r1.59 D04parameter.ztst
--- Test/D04parameter.ztst 3 Jun 2011 22:03:44 -0000 1.59
+++ Test/D04parameter.ztst 16 Aug 2011 14:50:13 -0000
@@ -1453,3 +1453,8 @@
print ${foo:5:-6}
1:Regression test for total length < 0 in array
?(eval):2: substring expression: 3 < 5
+
+ foo=(${(0)"$(print -n)"})
+ print ${#foo}
+0:Nularg removed from split empty string
+>0
--
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
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Messages sorted by:
Reverse Date,
Date,
Thread,
Author