Debugging on part(s) of the bash script

Using the set Bash built-in you can run in normal mode those portions of the script of which you are sure they are without fault, and display debugging information only for troublesome zones. Say we are not sure what the w command will do in the example commented-script1.sh, then we could enclose it in the script like this.

set -x # activate debugging from here
w
set +x # stop debugging from here

You can switch debugging mode on and off as many times as you want within the same script.

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.