Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: DEBUG trap and warn_create_global



On Sun, Nov 19, 2017 at 8:08 PM, Matthew Martin <phy1729@xxxxxxxxx> wrote:
>
> I would think ZSH_DEBUG_CMD is local to the trap execution. Otherwise
> DEBUG traps can "break" warn_create_global clean functions.

Hm.  Making it implicitly local would change the behavior with respect
to "unset after the trap."  I don't know how important that is.

However, it should be possible for it to be set without tripping the
warning, we just need to call assignsparam() instead of setsparam().

(Apologies if this gets wordwrapped or something, I don't have access
to my usual email client this week.)

diff --git a/Src/exec.c b/Src/exec.c
index fc6d02d..49da562 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1319,7 +1319,9 @@ execlist(Estate state, int dont_change_job, int exiting)
            noerrexit = NOERREXIT_EXIT | NOERREXIT_RETURN;
            if (ltype & Z_SIMPLE) /* skip the line number */
                pc2++;
-           pm = setsparam("ZSH_DEBUG_CMD", getpermtext(state->prog, pc2, 0));
+           pm = assignsparam("ZSH_DEBUG_CMD",
+                              getpermtext(state->prog, pc2, 0),
+                              0);

            exiting = donetrap;
            ret = lastval;



Messages sorted by: Reverse Date, Date, Thread, Author