Using the bash -x and -v options
Up to this point, we have tried debugging using different methods that involved commands inserted into our scripts. Regardless of the command we used, this approach has one drawback – whatever we do, using commands inside the script is either very localized to a particular part of a given script or too global since it has to cover a good chunk of code. We are not saying that this is not a valid way of solving problems in scripts, but we still need more ways to debug.
Getting ready
The only thing we need to know before we start using this is that we will be running scripts by invoking them as parameters of the interpreter, so something like this:
bash -options <scriptname>
This is important since we can not use any of these options if we invoke scripts in any other way.
How to do it…
Bash is in this respect pretty complicated since it offers little, in fact almost nothing, in terms of support for any reasonable...