zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Eric Cook <llua@gmx.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] _complete_debug: do not clobber PS4/PROMPT4
Date: Sun, 3 Jul 2022 21:32:42 -0700	[thread overview]
Message-ID: <CAH+w=7Zi+TAjd1cQ0NsLhp1wpeKJpSXe0hH85vPESfoZK+ZyHw@mail.gmail.com> (raw)
In-Reply-To: <0404aac5-7212-2c10-7202-60400fc4222d@gmx.com>

On Sat, Jul 2, 2022 at 7:44 PM Eric Cook <llua@gmx.com> wrote:
>
> So unless there is a reason that I am missing, the following patch should stop _complete_debug from overwriting
> PS4/PROMPT4

All of these paired variables -- PROMPT/PS1, PROMPT2/PS2, etc. -- are
implemented the same way, by pointers to the same internal C string.
Even if one is local and the other is not, they can't have different
values (which can be its own strange effect).  Due to the way local
variables are implemented, this means that when the local scope ends
the previous values of all the locals are restored in what amounts to
random order ... so you may or may not see the behavior you described.

> -  local PROMPT4 PS4="${(j::)debug_indent}+%N:%i> "
> +  local PS4="${(j::)debug_indent}+%N:%i> "

Although I can't imagine why a completion function would change
PROMPT4, I still think it's odd for one of the pair to be local and
the other not.  I suggest instead:

local PROMPT4="$PROMPT4" PS4="${(j::)debug_indent}+%N:%i> "

This will force the up-scope value of both variables to be restored
properly regardless of the order in which they're unwound, and
correctly identifies PROMPT4 as local to called scopes.


      reply	other threads:[~2022-07-04  4:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-03  2:43 Eric Cook
2022-07-04  4:32 ` Bart Schaefer [this message]

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=7Zi+TAjd1cQ0NsLhp1wpeKJpSXe0hH85vPESfoZK+ZyHw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=llua@gmx.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).