From b16d754d9cc36b5bcf506d95621ad3bd69238ab7 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 25 Jun 2015 17:01:48 +0100 Subject: 35604: create empty arrays in typeset with array=() --- ChangeLog | 5 +++++ Src/exec.c | 21 ++++++++++++--------- Test/B02typeset.ztst | 13 +++++++++++++ 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 + + * 35604: Src/exec.c, Test/B02typeset: create + empty arrays in typeset with array=(). + 2015-06-24 Jun-ichi Takimoto * 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 -- cgit 1.4.1