zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _complete_debug: do not clobber PS4/PROMPT4
@ 2022-07-03  2:43 Eric Cook
  2022-07-04  4:32 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Cook @ 2022-07-03  2:43 UTC (permalink / raw)
  To: Zsh hackers list

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}




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-04  4:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-03  2:43 [PATCH] _complete_debug: do not clobber PS4/PROMPT4 Eric Cook
2022-07-04  4:32 ` Bart Schaefer

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).