Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Accessing the evaluated expression which caused an error
- X-seq: zsh-users 27077
- From: Zach Riggle <zachriggle@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Accessing the evaluated expression which caused an error
- Date: Thu, 2 Sep 2021 20:42:46 -0500
- Archived-at: <https://zsh.org/users/27077>
- List-id: <zsh-users.zsh.org>
I have a neat script that registers a TRAPERR function, which dumps
out a backtrace, with the filename, line of source, and a few lines of
source around the line where the error was triggered. Here's a
contrived example: https://i.imgur.com/jDOa8Pq.png
This is done using funcfiletrace, funcstack, and syntax-highlighted
with 'bat'. 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.
These are excellent to show a backtrace, but I'm curious whether there
are additional functions that I might be able to leverage to show the
fully-evaluated expression which caused TRAPERR to be invoked.
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.
I looked through the docs, as well as the output of "env" and
"declare" from within TRAPERR, but couldn't find anything helpful.
Thanks!
Zach Riggle
Messages sorted by:
Reverse Date,
Date,
Thread,
Author