Linux Shell Script Debugging Techniques (PS4 BASH_XTRACEFD)
This article continues to share some debugging techniques. 1. Use PS4 for Custom Debug Output You can specify the output format of set -x using the PS4 variable: #!/usr/bin/env bash # ps4.sh # Custom debug prompt export PS4='+ ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' set -x # Now the debug output will show the filename and line number … Read more