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

Re: Preventing xtrace / -x from stepping through function from autoload'ed module

On Wed, Aug 11, 2021 at 1:36 AM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
> Documentation on "typeset" indicates that with the "-f" flag, "-ft"
> should turn ON tracing for that function, and "-fT" should turn OFF
> tracing for that function (as long as it is named).

No, that's not correct.

"typeset -ft funcname" turns on tracing for funcname and for every
other function called by funcname during its execution.

"typeset -fT funcname" turns on function tracing for funcname only,
that is, does not keep it on for other functions called by funcname.

Thus "typeset -fT func" will in fact disable the global xtrace for
other functions called by func, but not for func itself.  Those other
functions may of course turn xtrace back on again as a consequence of
"typeset -ft" or (inside the function) "setopt xtrace".  Note in the
example below that
  functions -T innerfunc
disables tracing within bottomfunc.

% topfunc() { print $0; innerfunc }
% innerfunc() { print $0; bottomfunc }
% bottomfunc() { print $0 and done }
% functions -t topfunc
% functions -T innerfunc
% topfunc
+topfunc:0> print topfunc
+topfunc:0> innerfunc
+innerfunc:0> print innerfunc
+innerfunc:0> bottomfunc
bottomfunc and done

Messages sorted by: Reverse Date, Date, Thread, Author