Will the (e) actually evaluate the parameters and execute them again? Or just a single layer of expansion?

On Sat, Sep 4, 2021 at 3:08 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
On Fri, Sep 3, 2021 at 10:38 AM Zach Riggle <zachriggle@gmail.com> 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.
--

Zach Riggle