The debugger normally lists the line number and source line of the for the statement to be next executed. Often this line contains one expression or one statement and it is clear from this line what’s going to happen. However BASH allows many expressions or statements to be put on a single source line; some lines contain several units of execution. Some examples of this behavior are listed below:
x=1; y=2; x=3 (( x > 5 )) && x=5 y=`echo *`
In the first line of the example above, we have three assignment statements on a single line. In the second line of the example above we have a statement which gets run only if a condition tests true. And in the third line of the example above, we have a command that gets run and then the output of that is substituted in an assignment statement. If you were single stepping inside the debugger, each line might get listed more than once before each of the actions that might get performed. (In the case of the conditional statement, the line gets listed only once when the condition is false.)
In order to assist understanding where you are, the enhanced version
of BASH maintains a dynamic variable BASH_COMMAND
that
contains piece of code next to be run (or is currently being run). The
debugger has arranged to save this and can display this information
or not. This is controlled by set showcommand
.
set showcommand [auto | on | 1 | off | 0 ]
¶controls whether or not to show the saved BASH_COMMAND
for the
command next to be executed.
When the value is auto
the following heuristic is used to
determine whether or not to display the saved BASH_COMMAND
. If
the last time you stopped you were at the same place and the command
string has changed, then show the command. When the value on
is
used, the debugger always shows BASH_COMMAND
and when
off
is used, the debugger never shows
BASH_COMMAND
. Note that listing the text of the source line is
independent of whether or not the command is also listed.
Some examples:
set showcommand auto This is the default set showcommand on Always show the next command to be executed set showcommand off Never show the next command to be executed