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 26972
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Cc: Zach Riggle <zachriggle@xxxxxxxxx>
- Subject: Re: Prevent a specific function from being xtrace'd
- Date: Tue, 24 Aug 2021 13:09:28 +0000
- Archived-at: <https://zsh.org/users/26972>
- 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>
Bart Schaefer wrote on Mon, Aug 23, 2021 at 13:04:42 -0700:
> 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.
Another idea: instead of «set -x» globally, use «functions -T» on every
function except the ones you don't want to trace, as in:
[[[
% f() { g }
% g() { h }
% h() { pwd }
% functions -mT '*'
% functions +T g
% f
+f:7> g
+h:7> pwd
/home/daniel
]]]
This won't apply tracing to top-level code (outside of a function).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author