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

Re: There's no xtrace output for function definitions



On Wed, Jun 8, 2022 at 9:45 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Obviously (I would think) we don't want to dump the entire function
> body to stderr, but we ought to output something?

In the "I've forgotten more than I still know" department, I just
realized that other shells don't trace function definitions either.

Consequently, the following is submitted for consideration, but I
won't commit it.  (I hope gmail isn't actually messing up indentation
as much as I think it might be.)

diff --git a/Src/exec.c b/Src/exec.c
index f2911807c..6d08f5e7e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5364,6 +5364,11 @@ execfuncdef(Estate state, Eprog redir_prog)
         zfree(shf, sizeof(*shf));
         break;
     } else {
+        if (isset(XTRACE) && EMULATION(EMULATE_ZSH)) {
+        fprintf(xtrerr, "function ");
+        quotedzputs(s, xtrerr);
+        fputc('\n', xtrerr);
+        }
         /* is this shell function a signal trap? */
         if (!strncmp(s, "TRAP", 4) &&
         (signum = getsignum(s + 4)) != -1) {




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