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

Re: A question about debugging zsh using set -x to an independent log file



On Apr 22,  7:56pm, Steven Lu wrote:
} 
} The problem is that this is a heisenbug and it comes and goes, the shell
} will be simply unusable when the xtrace output is there, and I can't really
} use the shell effectively if I redirect stderr to a file.

You probably want to use a trap on the DEBUG pseudo-signal, e.g.,

    TRAPDEBUG() {
      print -r -- "$ZSH_DEBUG_CMD" >> your_trace_file
    }

Or for closer congruence to set -x

    trap '{ print -nP -- "$PS4"
            print -r -- "$ZSH_DEBUG_CMD" } >> your_trace_file' DEBUG

This requires "setopt DEBUG_BEFORE_CMD" but unless you've deliberately
unset that, it is set by default.



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