2.1.2 Having bash invoke the debugger and your shell script

bash --debugger script script-arguments...

This calls a debugger initialization script. It works much like a BASH login profile which may set variables and define functions. But this shell profile is customized for debugging and as such arranges for itself to get called before each statement is executed. Although there are some problems at present in I/O redirection that the method described next doesn’t have, it is expected that over time more features will be enabled in bash when the ‘--debugger’ option is in effect.

When you use ‘bash --debugger’ and the bash script you want to debug needs arguments, you need to disambiguate which place arguments are to be sent to: bash, or your program.

To disambiguate add ‘--’ after your script name. For example:

bash --debugger ~/path/to/my/myscript.sh -- -o sample.out --option2

Without the ‘--’, bash will thing that ‘-o sample.out‘ is to be handled by bash, rather than ‘myscript.sh’.

Alternatively you can set arguments the debuggerd script using bash’s ‘set’ command like this:

set -o sample.out --option2