zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] Appending an array to a scalar
Date: Mon, 26 Feb 2024 20:56:23 -0800	[thread overview]
Message-ID: <CAH+w=7aWpzwxJdopO+=k7L0KwYwPeQQhU_XrW2k2M3Yu_2cGJA@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZePAx3FfKvOMu28WdiuFHV3oHQSEb3fjj0oiefovL0Vw@mail.gmail.com>

On Mon, Feb 26, 2024 at 6:51 PM Bart Schaefer <schaefer@brasslantern.com> 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);


  reply	other threads:[~2024-02-27  4:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 22:18 Assigning an array to a nameref "placeholder" Bart Schaefer
2024-02-27  2:51 ` Bart Schaefer
2024-02-27  4:56   ` Bart Schaefer [this message]
2024-02-27  6:48 ` Stephane Chazelas
2024-02-28  2:10   ` Bart Schaefer
2024-02-28  5:28     ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7aWpzwxJdopO+=k7L0KwYwPeQQhU_XrW2k2M3Yu_2cGJA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).