about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-06-25 17:01:48 +0100
committerPeter Stephenson <pws@zsh.org>2015-06-25 17:01:48 +0100
commitb16d754d9cc36b5bcf506d95621ad3bd69238ab7 (patch)
tree21314d7fb8b935faf863aa3040b573c4bec886d2
parent0d7be4af0dc6efa30a187ba4f897f773460a2944 (diff)
downloadzsh-b16d754d9cc36b5bcf506d95621ad3bd69238ab7.tar.gz
zsh-b16d754d9cc36b5bcf506d95621ad3bd69238ab7.tar.xz
zsh-b16d754d9cc36b5bcf506d95621ad3bd69238ab7.zip
35604: create empty arrays in typeset with array=()
-rw-r--r--ChangeLog5
-rw-r--r--Src/exec.c21
-rw-r--r--Test/B02typeset.ztst13
3 files changed, 30 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 574e5fa73..b2d01f34a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-25  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 35604: Src/exec.c, Test/B02typeset: create
+	empty arrays in typeset with array=().
+
 2015-06-24  Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
 
 	* 35550: Src/Zle/complist.c: fix backspace in interactive
diff --git a/Src/exec.c b/Src/exec.c
index 57e8f6376..50a11eb54 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3583,15 +3583,18 @@ execcmd(Estate state, int input, int output, int how, int last1)
 			    asg->value.array =
 				ecgetlist(state, WC_ASSIGN_NUM(ac),
 					  EC_DUPTOK, &htok);
-			    prefork(asg->value.array, PREFORK_ASSIGN);
-			    if (errflag) {
-				state->pc = opc;
-				break;
-			    }
-			    globlist(asg->value.array, 0);
-			    if (errflag) {
-				state->pc = opc;
-				break;
+			    if (asg->value.array)
+			    {
+				prefork(asg->value.array, PREFORK_ASSIGN);
+				if (errflag) {
+				    state->pc = opc;
+				    break;
+				}
+				globlist(asg->value.array, 0);
+				if (errflag) {
+				    state->pc = opc;
+				    break;
+				}
 			    }
 			}
 
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index e6285bc05..1548b817b 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -663,3 +663,16 @@
 >fn2 () {
 >  typeset assignfirst=(why not) 
 >}
+
+  fn() {
+    typeset array=()
+    print ${(t)array} ${#array}
+    typeset gnothergarray=() gnothergarray[1]=yes gnothergarray[2]=no
+    print -l ${(t)gnothergarray} $gnothergarray
+  }
+  fn
+0:can set empty array
+>array-local 0
+>array-local
+>yes
+>no