Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Prevent a specific function from being xtrace'd
- X-seq: zsh-users 26970
- From: Zach Riggle <zachriggle@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Prevent a specific function from being xtrace'd
- Date: Mon, 23 Aug 2021 18:23:02 -0500
- Archived-at: <https://zsh.org/users/26970>
- In-reply-to: <CAH+w=7bOCbkjRhGj8HjeJ6t-uyg7Uye26M5NnLqai+ThyXR_5A@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5==SoZuvHHB3U+HYu5+KwXMa7Jifjf_TFd31yxrhBiA1w@mail.gmail.com> <CAH+w=7bOCbkjRhGj8HjeJ6t-uyg7Uye26M5NnLqai+ThyXR_5A@mail.gmail.com>
>>> local first_line=$(head -1 <<<$ZSH_DEBUG_CMD)
> Egad.
> local first_line=${ZSH_DEBUG_CMD%%$'\n'*}
That's (almost!) the following line! I couldn't quite get it to work,
looks like I was missing a $ and the *.
Thanks!
Zach Riggle
Zach Riggle
On Mon, Aug 23, 2021 at 3:04 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Aug 23, 2021 at 9:42 AM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
> >
> > Hello all!
> >
> > ~~ TL; DR ~~
> > Is there any way to mark or annotate a function such that its internals should not be traced, even if "set -x" or "zsh -x" is used?
>
> emulate zsh +x -c 'autoload untraced'
>
> (The name "untraced" is for example, not some sort of extra magic.)
> It also works for
>
> emulate zsh +x -c 'untraced() { ... }'
>
> but that requires that you're careful about quoting in the function body.
>
> Of course you can still force tracing back on with
> functions -t untraced
> or the function internally calling "set -x" etc.
>
> > I've created a small script[1] that somewhat achieves this effect, with TRAPDEBUG and ZSH_DEBUG_COMMAND
>
> >> local first_line=$(head -1 <<<$ZSH_DEBUG_CMD)
>
> Egad.
>
> local first_line=${ZSH_DEBUG_CMD%%$'\n'*}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author