-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.sh
More file actions
executable file
·30 lines (26 loc) · 919 Bytes
/
Copy pathdebug.sh
File metadata and controls
executable file
·30 lines (26 loc) · 919 Bytes
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
#!/usr/bin/env bash
# Get the directory of the current script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$SCRIPT_DIR/load_color_codes.def"
# Debug function to run or display debug messages only when debug mode is enabled
debug() {
if [ "${DEBUG_MODE:=0}" -eq 1 ]; then
if type "$1" &>/dev/null; then
if [[ "$1" == "set" ]]; then
# Run 'set' command bare so options like -xv take effect
"$@"
else
"$@" 2>&1 | sed -e "s,^,DEBUG: ," 1>&2
fi
else
echo "DEBUG: $*" 1>&2
fi
fi
}
# Source footer if it exists
if [ -f "$SCRIPT_DIR/bash_footer.template.live" ]; then
source "$SCRIPT_DIR/bash_footer.template.live"
else
echo -e "${RED}Footer template missing. Skipping...${RESET}"
echo -e "Please ensure 'bash_footer.template.live' exists in the same directory."
fi