Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _complete_debug: do not clobber PS4/PROMPT4
- X-seq: zsh-workers 50398
- From: Eric Cook <llua@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] _complete_debug: do not clobber PS4/PROMPT4
- Date: Sat, 2 Jul 2022 22:43:57 -0400
- Archived-at: <https://zsh.org/workers/50398>
- List-id: <zsh-workers.zsh.org>
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}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author