about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-02-16 08:43:46 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-02-16 08:43:46 +0000
commit04e1ef5b681eba06c29f5149fcc18412b7f0f8e4 (patch)
tree67fdaea647850f603c7ce53aedea259ae15ed35f
parent12ef192f31a8b3ebe27c2cb693396dcb05ba9bb2 (diff)
downloadzsh-04e1ef5b681eba06c29f5149fcc18412b7f0f8e4.tar.gz
zsh-04e1ef5b681eba06c29f5149fcc18412b7f0f8e4.tar.xz
zsh-04e1ef5b681eba06c29f5149fcc18412b7f0f8e4.zip
Partial sh emulation fixs for ${1+"$@"} and "${foo=$@}".
-rw-r--r--ChangeLog7
-rw-r--r--Src/subst.c17
2 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8021fcbd9..918efedfe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-02-16  Bart Schaefer  <schaefer@brasslantern.com>
+
+	* 13492: Src/subst.c: Partial fix for ${1+"$@"} expanding to
+	an array (still doesn't handle shwordsplit properly); fix so
+	"${(A)foo=$@}" does *not* expand to an array, even though an
+	array is assigned to $foo.
+
 2001-02-14  Clint Adams  <schizo@debian.org>
 
 	* unposted: Src/params.c: remove unused variable declaration.
diff --git a/Src/subst.c b/Src/subst.c
index bb90faf0c..da848779a 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1379,7 +1379,14 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	case '-':
 	    if (vunset) {
 		val = dupstring(s);
-		multsub(&val, NULL, &isarr, NULL);
+		/*
+		 * This is not good enough for sh emulation!  Sh would
+		 * split unquoted substrings, yet not split quoted ones
+		 * (except according to $@ rules); but this leaves the
+		 * unquoted substrings unsplit, and other code below
+		 * for spbreak splits even within the quoted substrings.
+		 */
+		multsub(&val, (aspar ? NULL : &aval), &isarr, NULL);
 		copied = 1;
 	    }
 	    break;
@@ -1446,6 +1453,14 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		}
 		*idend = sav;
 		copied = 1;
+		if (isarr) {
+		  if (nojoin)
+		    isarr = -1;
+		  if (qt && !getlen && isarr > 0) {
+		    val = sepjoin(aval, sep, 1);
+		    isarr = 0;
+		  }
+		}
 	    }
 	    break;
 	case '?':