Skip to content

Instantly share code, notes, and snippets.

@dgoade
Created May 2, 2015 13:13
Show Gist options
  • Save dgoade/e969042e4917a1e1c9e8 to your computer and use it in GitHub Desktop.
Save dgoade/e969042e4917a1e1c9e8 to your computer and use it in GitHub Desktop.
Bash Cookbook: Debugging
#!/bin/bash
# From: https://github.com/dgoade/bat/blob/master/lib/utils.sh
##== FUNCTION ==========================================================================
: <<='cut'
=head2 B<utils_trace_on()>
Debugging tool. Toggle-on Bash x-trace with a special prompt that shows
the script name, function name and line number along with the output.
B<ARGUMENTS:>
None
B<RETURNS:>
None
B<GLOBALS USED:>
None
B<DEPENDENCIES:>
None
B<NOTES:>
None
B<BUGS:>
None
B<SEE ALSO:>
L</utils_trace_off()>,
L</utils_stacktrace()>,
L<utils_callStack(I<[start]>)|/utils_callStack([start])>,
L<utils_debugme([I<commands>...])|/utils_debugme([commands...])>
=cut
##======================================================================================
utils_trace_on()
{
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -x
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment