Skip to content

Commit 8f28b76

Browse files
committed
And and improve debugging code
1 parent 41a342d commit 8f28b76

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

content/articles/bash/script-template.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ set -u
2222
# Fail if any command in a pipeline fails (not just the last one)
2323
set -o pipefail
2424

25+
# Enable for debugging
26+
#set -x
27+
#PS4='+ ${BASH_SOURCE}:${LINENO}: '
2528
# Print line at which the script failed, if it failed (due to "set -e").
26-
trap 'print_error "Script failed at line $LINENO"' ERR
29+
# NOTE: There are a lot of issues when using $(...) with traps (i.e. they don't work as
30+
# expected). That's why this isn't enabled by default.
31+
#trap 'print_error "Script failed at line $LINENO"' ERR
2732

2833
# Configuration
2934
SCRIPT_NAME="$(basename "$0")"

0 commit comments

Comments
 (0)