-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebugging.sh
43 lines (38 loc) · 1.41 KB
/
debugging.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
DEBUG=${DEBUG:-true}
#=== FUNCTION ================================================================
# NAME: debug_on
# DESCRIPTION: turns on bash debugging output
#===============================================================================
debug_on() {
$DEBUG || return
set -x
} # end of function debug_on
#=== FUNCTION ================================================================
# NAME: debug_off
# DESCRIPTION: turns off bash debugging output
#===============================================================================
debug_off() {
$DEBUG || return
set +x
} # end of function debug_off
#=== FUNCTION ================================================================
# NAME: debug
# PARAMETER: string
# DESCRIPTION: outputs parameter(s) to stderr
#===============================================================================
debug() {
$DEBUG || return
echo -e "[$(date '+%H:%M:%S')] ${*}" > /dev/stderr
} # end of function debug
#=== FUNCTION ================================================================
# NAME: breakpoint
# PARAMETER: string
# DESCRIPTION: outputs parameter(s) to stderr and then pauses
#===============================================================================
breakpoint() {
$DEBUG || return
debug "-breakpoint- ${*}"
echo "press any key to continue"
read -r
} # end of function breakpoint