Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Appending an array to a scalar
- X-seq: zsh-workers 52619
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] Appending an array to a scalar
- Date: Mon, 26 Feb 2024 20:56:23 -0800
- Archived-at: <https://zsh.org/workers/52619>
- In-reply-to: <CAH+w=7ZePAx3FfKvOMu28WdiuFHV3oHQSEb3fjj0oiefovL0Vw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7YPkNSiSC_mp-THHvV-fV_rnbrrhVy6Q00ybeszVPUeyw@mail.gmail.com> <CAH+w=7ZePAx3FfKvOMu28WdiuFHV3oHQSEb3fjj0oiefovL0Vw@mail.gmail.com>
On Mon, Feb 26, 2024 at 6:51 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> % x+=(a b)
> % typeset -p x
> typeset -a x=( '' a b )
>
> This has been the case for as long as += has been around, as far as I
> can tell. Works this way even with typesettounset
Hm, this is actually consistent with ksh, except for the
typesettounset bit, which is a recent addition.
diff --git a/Src/params.c b/Src/params.c
index 225acb8a1..8fb73f6a0 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3345,7 +3345,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);
Messages sorted by:
Reverse Date,
Date,
Thread,
Author