Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Function trace in bash vs. POSIX

21 views
Skip to first unread message

HB_...@aapt.net.au

unread,
Jan 26, 2016, 8:31:05 PM1/26/16
to
Using the POSIX shell (HP-UX), the trace directives set [-+]x and typeset [-+]ft interact as follows (regardless of whether shell functions are defined with the "function name" or "name()" forms):

set -x:
- typeset -ft
Caller and named function(s) traced

- typeset +ft
Caller but trace from named function(s) suppressed


set +x:
- typeset -ft
Only named function(s) traced

- typeset +ft
No trace at all


So function trace is governed independently of the calling script/session trace, which can be useful in controlling the amount of trace so generated.

Now under bash 4.1.2 (RHEL 2.6.32) (and 4.3.27 HP-UX 11.31), I get this:

set -x:
Caller and all functions traced, irrespective of typeset [-+]ft

set -x:
No trace at all, irrespective of trace -ft


While I've found plenty of stuff showing how to use typeset -ft to generate trace, I haven't found anything going the other way, i.e. actually limiting the amount of function-level trace.

Any insights on this one ?

Thanks.

Joerg.S...@fokus.fraunhofer.de

unread,
Jan 27, 2016, 5:07:53 AM1/27/16
to
In article <2db9d18b-ae5b-4ef5...@googlegroups.com>,
<HB_...@aapt.net.au> wrote:
>Using the POSIX shell (HP-UX), the trace directives set [-+]x and typeset [-+]ft interact as follows (regardless of whether shell functions are
>defined with the "function name" or "name()" forms):
>
>set -x:
>- typeset -ft
>Caller and named function(s) traced
>
>- typeset +ft
>Caller but trace from named function(s) suppressed

"typeset" is not part of POSIX, so you cannot make any conclusions from that.

"typeset" is rather a ksh88 feature that may have been (more or less similar)
reimplemented in other shells.

--
EMail:jo...@schily.net (home) Jörg Schilling D-13353 Berlin
joerg.s...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.org/private/ http://sourceforge.net/projects/schilytools/files/
0 new messages