GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
* Sign Up! *

Support
Customer Portal
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DEBUG.SH(8) FreeBSD System Manager's Manual DEBUG.SH(8)

debug.shselectively debug scripts

debug.sh provides the following functions to facilitate flexible run-time tracing of complicated shell scripts.

[-eo] tag ...
turns tracing on if any tag is found in DEBUG_SH (a comma separated list of tags).

It turns tracing off if !tag is found in DEBUG_SH.

It sets DEBUG_ON to the tag that caused tracing to be enabled, or DEBUG_OFF if we matched !tag.

If -e option is present, returns 1 if no tag matched.

If -o option is present, tracing is turned off unless there was a matched tag, useful for functions too noisy to tace.

[-eo] [rc=rc] tag ...
turns tracing on if any tag matches DEBUG_OFF or off if any tag matches DEBUG_ON. This allows nested functions to not interfere with each other.

The flags -e and -o are ignored, they just allow for symmetry with calls to ().

The optional rc value will be returned rather than the default of 0. Thus if () is the last operation in a function, rc will be the return code of the function.

returns true if tracing is enabled. It is useful for bounding complex debug actions, rather than using lots of $DEBUG_DO lines.
tag
Add tag to DEBUG_SH to influence later output, possibly in a child process.
is just shorthand for:
$DEBUG_DO echo "$@"
[message]
If debugging is enabled, output message prefixed with a time-stamp.
tag ...
runs an interactive shell if any tag is found in DEBUG_INTERACTIVE, and there is a tty available. The shell used is defined by DEBUG_SHELL or SHELL and defaults to /bin/sh.
message
Debug output can be very noisy, and it can be tricky to align with the script. This function outputs a very noticeable banner indicating the value of DEBUG_ON, and message is passed to DebugLog(), finally the banner is repeated.
tag ...
For backwards compatibility, calls DebugOn() and if that does not turn tracing on, it calls DebugOff() to turn it off.

The variables DEBUG_SKIP and DEBUG_DO are set so as to enable/disable code that should be skipped/run when debugging is turned on. DEBUGGING is the same as DEBUG_SKIP for backwards compatibility and is only set by ().

The use of $_DEBUG_SH is to prevent multiple inclusion, though it does no harm in this case.

Does not work with some versions of ksh(1). If a function turns tracing on, ksh turns it off when the function returns - useless.

PD ksh works ok ;-)

debug.sh was written by Simon J Gerraty <sjg@crufty.net>.

October 22, 2024 FreeBSD 15.1-RELEASE-p1

Search for    or go to Top of page |  Section 8 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.