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

Re: PATCH: fixing ${1+"$@"} when word-splitting



On Mon, Feb 13, 2006 at 06:08:57PM +0000, Peter Stephenson wrote:
> unfortunately the saga continues...

:-)  Yup.  Thanks for the extensive testing!

> % fn() { local IFS=.-; print -l ${=1:-$ZSH_VERSION}; }
> % fn
> 4.3.0-dev-3

The attached patch fixes this by temporarily setting SHWORDSPLIT
during the multsub() call when '=' was specified.  I also tested
that this change works properly with ${=1:-"$ZSH_VERSION"} (i.e.
giving the output above).

..wayne..
--- subst.c	2006-02-13 09:53:12.000000000 -0800
+++ subst.c	2006-02-13 10:50:52.000000000 -0800
@@ -2040,6 +2040,7 @@
 	/* Fall Through! */
 	case '-':
 	    if (vunset) {
+		int ws = opts[SHWORDSPLIT];
 		val = dupstring(s);
 		/* If word-splitting is enabled, we ask multsub() to split
 		 * the substituted string at unquoted whitespace.  Then, we
@@ -2048,7 +2049,9 @@
 		 * keep its array splits, and weird constructs such as
 		 * ${str+"one two" "3 2 1" foo "$str"} to only be split
 		 * at the unquoted spaces. */
+		opts[SHWORDSPLIT] = spbreak;
 		multsub(&val, spbreak && !aspar, (aspar ? NULL : &aval), &isarr, NULL);
+		opts[SHWORDSPLIT] = ws;
 		copied = 1;
 		spbreak = 0;
 	    }


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