zsh-users
 help / color / mirror / code / Atom feed
* Preventing xtrace / -x from stepping through function from autoload'ed module
@ 2021-08-11  8:36 Zach Riggle
  2021-08-11 17:48 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Zach Riggle @ 2021-08-11  8:36 UTC (permalink / raw)
  To: Zsh Users

Hello again, thanks in advance for the help.

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

However, quick experimentation doesn't align with my reading of the
docs -- "typeset -ft func" DOES work to enable tracing for that
function, but "typeset -fT func" does NOT disable tracing for that
function (when tracing is enabled globally via e.g. "set -x").

Are my expectations for "typeset -fT" out of line?  Its inverse,
"typeset -ft" does seem to work as I expect it to.

    #!/usr/bin/env zsh

    # Turn ON execution tracing
    set -x

    # Turn OFF execution tracing for the named function, before declaration
    typeset -fT hello

    hello() {
        echo "$@"
    }

    # Turn OFF execution tracing for the named function, after declaration
    # (not sure which order is intended so we try both.)
    typeset -fT hello

    # Testing shows that "hello" is traced, which is NOT expected
    hello "Should not be traced"

    # Turn ON function tracing for hello
    set +x
    typeset -ft hello

    # Testing shows that "hello" is traced, here as expected
    hello "Should be traced"


Zach Riggle


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Preventing xtrace / -x from stepping through function from autoload'ed module
  2021-08-11  8:36 Preventing xtrace / -x from stepping through function from autoload'ed module Zach Riggle
@ 2021-08-11 17:48 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2021-08-11 17:48 UTC (permalink / raw)
  To: Zach Riggle; +Cc: Zsh Users

On Wed, Aug 11, 2021 at 1:36 AM Zach Riggle <zachriggle@gmail.com> 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
+topfunc:0> innerfunc
+innerfunc:0> print innerfunc
innerfunc
+innerfunc:0> bottomfunc
bottomfunc and done
%


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-11 17:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11  8:36 Preventing xtrace / -x from stepping through function from autoload'ed module Zach Riggle
2021-08-11 17:48 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).