Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] _complete_debug: do not clobber PS4/PROMPT4
- X-seq: zsh-workers 50399
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Eric Cook <llua@xxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] _complete_debug: do not clobber PS4/PROMPT4
- Date: Sun, 3 Jul 2022 21:32:42 -0700
- Archived-at: <https://zsh.org/workers/50399>
- In-reply-to: <0404aac5-7212-2c10-7202-60400fc4222d@gmx.com>
- List-id: <zsh-workers.zsh.org>
- References: <0404aac5-7212-2c10-7202-60400fc4222d@gmx.com>
On Sat, Jul 2, 2022 at 7:44 PM Eric Cook <llua@xxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author