diff options
author | Peter Stephenson <pws@zsh.org> | 2015-06-26 14:55:35 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2015-06-26 14:55:35 +0100 |
commit | 42b9037ae5c1c62866d4dafee444f578c0335ff7 (patch) | |
tree | 6505195fbad3c646197f3478a89a92c0e977d609 | |
parent | 9265e49ccbe3f52f91be3f6c457a3db0dd2f8fbc (diff) | |
download | zsh-42b9037ae5c1c62866d4dafee444f578c0335ff7.tar.gz zsh-42b9037ae5c1c62866d4dafee444f578c0335ff7.tar.xz zsh-42b9037ae5c1c62866d4dafee444f578c0335ff7.zip |
35613: Handle array slices in typeset
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/builtin.c | 9 | ||||
-rw-r--r-- | Test/B02typeset.ztst | 15 |
3 files changed, 28 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 76aaf5c47..6778d3258 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-06-26 Peter Stephenson <p.stephenson@samsung.com> + + * 35613: Src/builtin.c, Test/B02typeset: handle + array slices in typeset. + 2015-06-25 Peter Stephenson <p.stephenson@samsung.com> * 35610: Src/builtin.c: typeset is silent if diff --git a/Src/builtin.c b/Src/builtin.c index bc685455d..3da16789a 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2347,9 +2347,16 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), asg->is_array = 0; keeplocal = 0; on = pm->node.flags; + } else if (PM_TYPE(on) == PM_ARRAY && ASG_ARRAYP(asg)) { + if (!(pm = setaparam(pname, asg->value.array ? zlinklist2array(asg->value.array) : + mkarray(NULL)))) + return NULL; + asg->value.array = NULL; + keeplocal = 0; + on = pm->node.flags; } else { zerrnam(cname, - "%s: array elements must be scalar", pname); + "%s: inconsistent array element or slice assignment", pname); return NULL; } } diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index 1548b817b..5d69e5dc2 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -676,3 +676,18 @@ >array-local >yes >no + + array=(nothing to see here) + fn() { + typeset array=(one two three four five) + typeset array[2,4]=(umm er) + print ${#array} $array + typeset array[2,3]=() + print ${#array} $array + } + fn + print ${#array} $array +0:can update array slices in typeset +>4 one umm er five +>2 one five +>4 nothing to see here |