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 26969
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zach Riggle <zachriggle@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Prevent a specific function from being xtrace'd
- Date: Mon, 23 Aug 2021 13:04:42 -0700
- Archived-at: <https://zsh.org/users/26969>
- In-reply-to: <CAMP9c5==SoZuvHHB3U+HYu5+KwXMa7Jifjf_TFd31yxrhBiA1w@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5==SoZuvHHB3U+HYu5+KwXMa7Jifjf_TFd31yxrhBiA1w@mail.gmail.com>
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