Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Accessing the evaluated expression which caused an error
- X-seq: zsh-users 27087
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zach Riggle <zachriggle@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Accessing the evaluated expression which caused an error
- Date: Sat, 4 Sep 2021 19:08:07 -0700
- Archived-at: <https://zsh.org/users/27087>
- In-reply-to: <CAMP9c5ngXWo4U2cjWeQtBr5+-tjA2gBu=Yi=k1STNkRidW1QAQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5mLwUce-23zmZAbCtHU+q-BzLbYTV482YcohXoj__ynZw@mail.gmail.com> <CAH+w=7aT6rgWDnfr0A=j7nrv2PjQMDJddefRhTg_VrmU2YF_6w@mail.gmail.com> <CAMP9c5ncfwHjWMaFuf=u6WhvNiN_UqMMArxtmHt4A+HqFMN0NA@mail.gmail.com> <CAH+w=7bb70xKOe_z+WAr3F6BUq2BUw8FQURbigWL1OpgETQx8w@mail.gmail.com> <CAMP9c5ngXWo4U2cjWeQtBr5+-tjA2gBu=Yi=k1STNkRidW1QAQ@mail.gmail.com>
On Sat, Sep 4, 2021 at 5:27 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> Will the (e) actually evaluate the parameters and execute them again? Or just a single layer of expansion?
Well ... it only does a single layer, but the string value of
ZSH_DEBUG_CMD is not itself specially quoted, so you only want to
apply (e) to cases like "${cmd[@]}" where you've deliberately added an
extra layer of quoting and want to peek inside it.
Then of course you probably want to put the quoting back again ... I
guess it ends up something like:
TRAPDEBUG() {
if function {
setopt localoptions extendedglob
[[ $ZSH_DEBUG_CMD = \"[^\"](#c1,)\" ]]
}
then ZSH_DEBUG_CMD=${(@q-)${(z)${(e)${(Q)ZSH_DEBUG_CMD}}}}
fi
print -r -- $ZSH_DEBUG_CMD
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author