zsh-workers
 help / color / mirror / code / Atom feed
From: Eric Cook <llua@gmx.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] _complete_debug: do not clobber PS4/PROMPT4
Date: Sat, 2 Jul 2022 22:43:57 -0400	[thread overview]
Message-ID: <0404aac5-7212-2c10-7202-60400fc4222d@gmx.com> (raw)

If you invoke _complete_debug (^X?) after it, you will notice that PS4 is set to empty string.

Which led me to line 22 of _complete_debug:

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

Within the scope of the function this seems to work(?) the output of the xtrace uses PS4's new value.
% (f() typeset -p PS4 PROMPT4; f;() { local PROMPT4 PS4=bar;typeset -p PROMPT4 PS4; }; f)
typeset -g PS4='+%N:%i> '
typeset -g PROMPT4='+%N:%i> '
typeset PROMPT4=bar
typeset PS4=bar
typeset -g PS4=''
typeset -g PROMPT4=''

I noticed that if you only local one of these two tied parameters, PS4/PROMPT4 outside of _complete_debug isn't
changed. regardless of which one is chosen while within the function scope, both are updated.
% (f() typeset -p PS4 PROMPT4; f;() { local PS4=bar;typeset -p PROMPT4 PS4; }; f)
typeset -g PS4='+%N:%i> '
typeset -g PROMPT4='+%N:%i> '
typeset -g PROMPT4=bar
typeset PS4=bar
typeset -g PS4='+%N:%i> '
typeset -g PROMPT4='+%N:%i> '

Seems to be long standing behavior and the oldest version of zsh i have available to me at the moment 4.3.12
have the same behavior.

Strangely enough the problem doesn't seem to be related PROMPT4 not being given a value during the local call.
(f() typeset -p PS4 PROMPT4; f;() { local PROMPT4=bar PS4=bar;typeset -p PROMPT4 PS4; }; f)
typeset -g PS4='+%N:%i> '
typeset -g PROMPT4='+%N:%i> '
typeset PROMPT4=bar
typeset PS4=bar
typeset -g PS4=bar
typeset -g PROMPT4=bar

So unless there is a reason that I am missing, the following patch should stop _complete_debug from overwriting
PS4/PROMPT4

diff --git a/Completion/Base/Widget/_complete_debug b/Completion/Base/Widget/_complete_debug
index 94fd4accd..f3a809f42 100644
--- a/Completion/Base/Widget/_complete_debug
+++ b/Completion/Base/Widget/_complete_debug
@@ -19,7 +19,7 @@ integer debug_fd=-1
      setopt localoptions no_ignorebraces
      debug_indent=( '%'{3..20}'(e. .)' )
    }
-  local PROMPT4 PS4="${(j::)debug_indent}+%N:%i> "
+  local PS4="${(j::)debug_indent}+%N:%i> "
    setopt xtrace
    : $ZSH_NAME $ZSH_VERSION
    ${1:-_main_complete}




             reply	other threads:[~2022-07-03  2:44 UTC|newest]

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

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=0404aac5-7212-2c10-7202-60400fc4222d@gmx.com \
    --to=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).