From 85172998f499cb789570714ffdd43f1ca3b53e58 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Wed, 28 Feb 2024 20:40:26 -0800 Subject: 52619 (plus tests): no empty element when appending array to unset scalar --- ChangeLog | 7 ++++++- Src/params.c | 2 +- Test/A06assign.ztst | 21 +++++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index e836a3853..9ab0218c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-02-28 Bart Schaefer + + * 52619 (plus tests): Src/params.c, Test/A06assign.ztst: there + is no empty element when appending array to unset scalar + 2024-02-28 Oliver Kiddle * 52622 (tweaked, c.f. 52626): Src/jobs.c: adjust number of columns @@ -54,7 +59,7 @@ x2024-02-19 Jun-ichi Takimoto * 52544: Completion/Unix/Type/_diff_options: support macOS Ventura or newer -2024-02-18 Bart Schaefer +2024-02-18 Bart Schaefer * 52558: Etc/FAQ.yo: make note of word splitting differences with nofork substitutions; update ToC; minor formatting fixes diff --git a/Src/params.c b/Src/params.c index 7c5e9d8ff..064dbd2bc 100644 --- a/Src/params.c +++ b/Src/params.c @@ -3355,7 +3355,7 @@ assignaparam(char *s, char **val, int flags) } else if (!(PM_TYPE(v->pm->node.flags) & (PM_ARRAY|PM_HASHED)) && !(v->pm->node.flags & (PM_SPECIAL|PM_TIED))) { int uniq = v->pm->node.flags & PM_UNIQUE; - if (flags & ASSPM_AUGMENT) { + if ((flags & ASSPM_AUGMENT) && !(v->pm->node.flags & PM_UNSET)) { /* insert old value at the beginning of the val array */ char **new; int lv = arrlen(val); diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst index f89edb888..3eff5331a 100644 --- a/Test/A06assign.ztst +++ b/Test/A06assign.ztst @@ -296,13 +296,26 @@ # tests of var+=(array) + a= + a+=(1 2 3) + print "${(q@)a}" +0:add array to empty parameter +>'' 1 2 3 + unset a a+=(1 2 3) - print -l $a + print "${(q@)a}" 0:add array to unset parameter ->1 ->2 ->3 +>1 2 3 + + () { + setopt localoptions typeset_to_unset + typeset a + a+=(1 2 3) + print "${(q@)a}" + } +0:add array to declared unset parameter +>1 2 3 a=(a) a+=(b) -- cgit 1.4.1