A downside of running script the way described in the previous
section, via ‘--debugger’, you must have the debugger scripts
installed in a place where the installed bash can find them. For this
reason, in developing the BASH debugger, I use a second method more often;
it doesn’t require the bash debugger to be installed. This method uses
another script called bashdb which allows for giving its own
options, the final option is signaled by adding --
). After
this, the name of the script to debugged and any the arguments to pass
to that script are given. Using this method, one would start the
debugger like this:
bash path-to-bashdb/bashdb script bashdb-options -- script-arguments...
If there is no possibilty of the BASH debugger confusing the program options with those used in your bash script, yyou don’t need to pass dash options to your program.
As with the first method, bash
should be a debugger-enabled
bash. If bashdb has the path to bash in it at the top (e.g. via
#!
), and bashdb can be found in your program-search
path, then this might be equivalent to the above:
bashdb bashdb-options script -- script-arguments...
There is a slight disadvantage to running a debugger this way: a traceback will contain additional lines showing the “source”-ing of the debugged script from bashdb.
An option that you’ll probably need to use if bashdb isn’t installed but run out of the source code directory is ‘-L’ which specifies the directory that contains the debugger script files.
You can further control how bashdb starts up by using command-line options. bashdb itself can remind you of the options available.
Type
bashdb -h
to display all available options and briefly describe their use.
When the bash debugger is invoked either by the bashdb
front-end script or bash --debugging
, the first argument that
does not have an associated option flag for bashdb or
bash
(as the case may be) is used as the name a the script file
to be debugged, and any following options get passed the debugged
script.
Options for the bashdb front-end are shown in the following list.