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

Re: Accessing the evaluated expression which caused an error



On Thu, Sep 2, 2021 at 6:43 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> I'm aware of funcsourcetrace, funcstack, and TRAPDEBUG /
> ZSH_DEBUG_CMD as well, but none of these contain the actual expression
> evaluated -- just the input to zsh.
>
> I know that zsh has the data internally, since "zsh -x" shows the
> fully-evaluated expression, so that data must be available somewhere,
> even if it's not exposed in a shell variable.

Hm.  What xtrace does is dump each individual shell word ... it just
happens to dump them in the order that puts them together as an
"expression".  But you'll notice it's not actually an expression, it's
just e.g. a single simple command.  In fact it's even a bit weird for
some structured commands (look at the output for a "case" statement
for example).

It's correct that none of this is captured in any sort of format that
would be usable by a shell script.  It never exists all at once in
such a format internally.

What exactly might you want captured?




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