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

Re: Accessing the evaluated expression which caused an error



On Fri, Sep 3, 2021 at 10:38 AM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> > What exactly might you want captured?
>
> Very frequently I build a create an array that contains a command [...]
> And invoke it like:
>
>     "${cmd[@]}"

Given that you're doing it that way (rather than say "eval" it), you
should be able to use TRAPDEBUG and just do this:

TRAPDEBUG() { ACTUAL_CMD=${(e)ZSH_DEBUG_CMD} }

You may want some other "protection" around that, such as only doing
it when ZSH_DEBUG_CMD matches a pattern.




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