Archive for the tag 'part(s)'

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 `uptime` command will do in a script, then we could enclose it in the script like this:

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

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.