help / color / mirror / code / Atom feed
From: Zach Riggle <zachriggle@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Accessing the evaluated expression which caused an error
Date: Thu, 2 Sep 2021 20:42:46 -0500	[thread overview]
Message-ID: <CAMP9c5mLwUce-23zmZAbCtHU+q-BzLbYTV482YcohXoj__ynZw@mail.gmail.com> (raw)

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.

Zach Riggle

             reply	other threads:[~2021-09-03  1:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03  1:42 Zach Riggle [this message]
2021-09-03 17:14 ` Bart Schaefer
2021-09-03 17:38   ` Zach Riggle
2021-09-04 20:08     ` Bart Schaefer
2021-09-05  0:26       ` Zach Riggle
2021-09-05  1:44         ` Lawrence Velázquez
2021-09-05  2:08         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMP9c5mLwUce-23zmZAbCtHU+q-BzLbYTV482YcohXoj__ynZw@mail.gmail.com \
    --to=zachriggle@gmail.com \
    --cc=zsh-users@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).