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

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



This must be a bug, mustn't it?

% foo=$'one\ntwo'
% print ${(z)foo}
one ; two

As far as splitting arguments goes, the newline is just whitespace.

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.98
diff -p -u -r1.98 hist.c
--- Src/hist.c	22 Mar 2010 23:20:11 -0000	1.98
+++ Src/hist.c	9 Jun 2010 13:05:20 -0000
@@ -2876,7 +2876,7 @@ bufferwords(LinkList list, char *buf, in
 		sprintf(b, "%d%s", tokfd, tokstrings[tok]);
 		addlinknode(list, dupstring(b));
 		num++;
-	    } else if (tok != NEWLIN) {
+	    } else if (tok != NEWLIN && tok != SEPER) {
 		addlinknode(list, dupstring(tokstrings[tok]));
 		num++;
 	    }
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.43
diff -p -u -r1.43 D04parameter.ztst
--- Test/D04parameter.ztst	12 May 2010 10:17:58 -0000	1.43
+++ Test/D04parameter.ztst	9 Jun 2010 13:05:20 -0000
@@ -389,6 +389,14 @@
 >)
 >ten( more
 
+  foo=$'first line\nsecond line'
+  print -l ${(z)foo}
+0:${(z)...} with newlines
+>first
+>line
+>second
+>line
+
   psvar=(dog)
   setopt promptsubst
   foo='It shouldn'\''t $(happen) to a %1v.'

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