about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-07-22 12:43:09 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-07-22 12:43:09 -0700
commitf3e8f4cf7a68a1e0e4356fc0f7e419ada338a3e0 (patch)
tree3ebca086e5e7ba373caf1750f2805ba5ba47cabc
parente63065e8e58069de8ea7a18a3830ef5b0f4f45f7 (diff)
downloadzsh-f3e8f4cf7a68a1e0e4356fc0f7e419ada338a3e0.tar.gz
zsh-f3e8f4cf7a68a1e0e4356fc0f7e419ada338a3e0.tar.xz
zsh-f3e8f4cf7a68a1e0e4356fc0f7e419ada338a3e0.zip
35581, 35582: output array assignments with spaces inside the parens
-rw-r--r--ChangeLog7
-rw-r--r--Src/params.c12
-rw-r--r--Test/A06assign.ztst2
-rw-r--r--Test/B02typeset.ztst6
4 files changed, 20 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ad2d53198..7e21be806 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-07-22  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 35582: Test/A06assign.ztst, Test/B02typeset.ztst: test for 35581
+
+	* 35581: Src/params.c: output array assignments with spaces inside
+	the parens
+
 2015-07-16  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* 35805: Test/E01options.ztst: tests for 35799
diff --git a/Src/params.c b/Src/params.c
index 7d0c8525e..312fa9ae1 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5099,8 +5099,10 @@ printparamvalue(Param p, int printflags)
 	break;
     case PM_ARRAY:
 	/* array */
-	if (!(printflags & PRINT_KV_PAIR))
+	if (!(printflags & PRINT_KV_PAIR)) {
 	    putchar('(');
+	    putchar(' ');
+	}
 	u = p->gsu.a->getfn(p);
 	if(*u) {
 	    quotedzputs(*u++, stdout);
@@ -5109,13 +5111,17 @@ printparamvalue(Param p, int printflags)
 		quotedzputs(*u++, stdout);
 	    }
 	}
-	if (!(printflags & PRINT_KV_PAIR))
+	if (!(printflags & PRINT_KV_PAIR)) {
+	    putchar(' ');
 	    putchar(')');
+	}
 	break;
     case PM_HASHED:
 	/* association */
-	if (!(printflags & PRINT_KV_PAIR))
+	if (!(printflags & PRINT_KV_PAIR)) {
 	    putchar('(');
+	    putchar(' ');
+	}
 	{
             HashTable ht = p->gsu.h->getfn(p);
             if (ht)
diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst
index a4401cb67..302659c7e 100644
--- a/Test/A06assign.ztst
+++ b/Test/A06assign.ztst
@@ -430,7 +430,7 @@
 0:GLOB_ASSIGN with numeric types
 >typeset -i i=0
 >typeset -a n
->n=(tmpfile1 tmpfile2)
+>n=( tmpfile1 tmpfile2 )
 >typeset x=tmpfile2
 >typeset -E f=4.000000000e+00
 
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 4c033cce7..05b3c16ea 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -453,7 +453,7 @@
  fn
 1:declare -p shouldn't create scoped values
 >typeset -a array
->array=(foo bar)
+>array=( foo bar )
 ?fn:typeset: no such variable: nonexistent
 
  unsetopt typesetsilent
@@ -504,10 +504,10 @@
   typeset -pm 'r[12]'
 0:readonly -p output
 >typeset -a a1
->a1=(one two)
+>a1=( one two )
 >typeset -ar a1
 >typeset -a a2
->a2=(three four)
+>a2=( three four )
 >typeset -r r1=yes
 >typeset -r r2=no