Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Prevent a specific function from being xtrace'd



>>> 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