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

Re: Bug with bash emulation regarding ':'



On Feb 19,  3:45pm, Bart Schaefer wrote:
}
} Consequently I tried this:
} 
}  		if (spsep || !arrasg) {
} -		    multsub(&val, PREFORK_NOSHWORDSPLIT, NULL, &isarr, NULL);
} +		    multsub(&val, PREFORK_SINGLE|PREFORK_NOSHWORDSPLIT, NULL,
} &isarr, NULL);
} 
} This faithfully reproduces the bash behavior in several tests I tried.

I should note that this wouldn't have been anywhere near this easy if
PWS hadn't done the background work on passing the bitflags.

Although all tests still pass (except the new one introduced by 30203
which must be tweaked), I should note the above changes the "native"
zsh behavior as well.  I woudn't imagine this is going to cause much
trouble -- I found no uses of ${...=...} in the default $fpath, which
includes the whole completion suite, etc. -- but it does mean we might
want to make it conditional upon something.  For example:

Index: Src/subst.c
--- ../zsh-forge/current/Src/subst.c	2012-02-12 13:31:49.000000000 -0800
+++ Src/subst.c	2012-02-20 00:32:30.000000000 -0800
@@ -2693,7 +2693,12 @@
 		*idend = '\0';
 		val = dupstring(s);
 		if (spsep || !arrasg) {
-		    multsub(&val, PREFORK_NOSHWORDSPLIT, NULL, &isarr, NULL);
+		    /* POSIX requires PREFORK_SINGLE semantics here, but
+		     * traditional zsh used PREFORK_NOSHWORDSPLIT.  Base
+		     * behavior on caller choice of PREFORK_SHWORDSPLIT. */
+		    multsub(&val,
+			    spbreak ? PREFORK_SINGLE : PREFORK_NOSHWORDSPLIT,
+			    NULL, &isarr, NULL);
 		} else {
 		    if (spbreak)
 			split_flags = PREFORK_SPLIT|PREFORK_SHWORDSPLIT;

I'd be just as happy going with PREFORK_SINGLE unconditionally, I think,
but I hesitate to change anything arbitrarily.  Either way, here is the
tweak to the test suite:

Index: Test/D04parameter.ztst
--- ../zsh-forge/current/Test/D04parameter.ztst	2012-02-12 13:31:49.000000000 -0800
+++ Test/D04parameter.ztst	2012-02-19 23:46:19.000000000 -0800
@@ -267,7 +267,9 @@
   : ${test_split_var:=$(test_splitting)}
   echo "_${test_split_var}_")
 0:SH_WORD_SPLIT inside $(...) inside ${...}
->_'one' 'two' 'three'_
+>_'one'
+>'two'
+>'three'_
 
   print -l "${(f)$(print first line\\nsecond line\\nthird line)}"
 0:${(f)$(...)}



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