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

Re: Changes for dev-4



On Thu, Feb 16, 2006 at 11:00:54AM +0000, Peter Stephenson wrote:
> +Bourne shells) or any of the related forms with the + replaced by - or =

Actually, I didn't change = because I was thinking that it would just
turn into a scalar anyway.  However, since the assignment might be to an
array, it could also benefit from the new array-split-preservation code.

Attached is a patch that fixes this.  Let me know if you agree that this
is something that should make it into 4.3.1.  (I'll check-in the first
tweak to the README file, since it fixes a typo.)

..wayne..
--- README	16 Feb 2006 14:28:54 -0000	1.27
+++ README	16 Feb 2006 18:50:28 -0000
@@ -30,7 +30,7 @@ The option SH_WORD_SPLIT, used in Bourne
 mode, has been made more like other shells in the case of substitutions of
 the form ${1+"$@"} (a common trick used to work around problems in older
 Bourne shells) or any of the related forms with the + replaced by - or =
-with an optional colon following.  Previously, with SH_WORD_SPLIT in
+with an optional colon preceding.  Previously, with SH_WORD_SPLIT in
 effect, this expression would cause splitting on all white space in the
 shell arguments.  (This was always regarded as a bug but was long-standing
 behaviour.)  Now it is treated identically to "$@".  The same change
--- Src/subst.c	15 Feb 2006 18:35:35 -0000	1.46
+++ Src/subst.c	16 Feb 2006 18:50:29 -0000
@@ -2070,27 +2070,23 @@ paramsubst(LinkList l, LinkNode n, char 
 	case '=':
 	case Equals:
 	    if (vunset) {
+		int ws = opts[SHWORDSPLIT];
 		char sav = *idend;
 		int l;
 
 		*idend = '\0';
 		val = dupstring(s);
-		/*
-		 * TODO: this is one of those places where I don't
-		 * think we want to do the joining until later on.
-		 * We also need to handle spbreak and spsep at this
-		 * point and unset them.
-		 */
-		if (spsep || spbreak || !arrasg)
+		if (spsep || !arrasg) {
+		    opts[SHWORDSPLIT] = 0;
 		    multsub(&val, 0, NULL, &isarr, NULL);
-		else
-		    multsub(&val, 0, &aval, &isarr, NULL);
+		} else {
+		    opts[SHWORDSPLIT] = spbreak;
+		    multsub(&val, spbreak, &aval, &isarr, NULL);
+		    spbreak = 0;
+		}
+		opts[SHWORDSPLIT] = ws;
 		if (arrasg) {
-		    /*
-		     * This is an array assignment in a context
-		     * where we have no syntactic way of finding
-		     * out what an array element is.  So we just guess.
-		     */
+		    /* This is an array assignment. */
 		    char *arr[2], **t, **a, **p;
 		    if (spsep || spbreak) {
 			aval = sepsplit(val, spsep, 0, 1);
--- Test/D04parameter.ztst	15 Feb 2006 18:38:58 -0000	1.15
+++ Test/D04parameter.ztst	16 Feb 2006 18:50:30 -0000
@@ -551,9 +551,10 @@
 
   local sure_that='sure that' varieties_of='varieties of' one=1 two=2
   extra=(5 4 3)
+  unset foo
   set Make $sure_that "this test keeps" on 'preserving all' "$varieties_of" quoted whitespace
   print -l ${=1+"$@"}
-  print -l ${=1+Make $sure_that "this test keeps" on 'preserving all' "$varieties_of" quoted whitespace}
+  print -l ${(A)=foo=Make $sure_that "this test keeps" on 'preserving all' "$varieties_of" quoted whitespace}
   print -l ${=1+$one $two}
   print -l ${1+$extra$two$one}
 0:Regression test of ${=1+"$@"} bug and some related expansions


Messages sorted by: Reverse Date, Date, Thread, Author