Previous: Disabling, Up: Breakpoints [Contents][Index]
The simplest sort of breakpoint breaks every time your script reaches a specified place. You can also specify a condition for a breakpoint. A condition is just a BASH expression.
Break conditions can be specified when a breakpoint is set, by using
‘if’ in the arguments to the break
command. See Setting breakpoints. A breakpoint with a condition
evaluates the expression each time your script reaches it, and your
script stops only if the condition is true. They can also be
changed at any time with the condition
command.
There is also a notion of a “one-time” breakpoint which gets deleted as soon as it is hit, so that that breakpoint is executed once only.
Conditions are also accepted for watchpoints; you may not need them, since a watchpoint is inspecting the value of an expression anyhow—but it might be simpler, say, to just set a watchpoint on a variable name, and specify a condition that tests whether the new value is an interesting one.
condition bnum expression
Specify expression as the break condition for breakpoint bnum. After you set a condition, breakpoint bnum stops your program only if the value of expression is true (nonzero).
condition bnum
Remove the condition from breakpoint number bnum. It becomes an ordinary unconditional breakpoint.
BASH does
not actually evaluate expression at the time the condition
command (or a command that sets a breakpoint with a condition, like
break if …
) is given, however.
Examples;
condition 1 x>5 # Stop on breakpoint 0 only if x>5 is true. condition 1 # Change that! Unconditinally stop on breakpoint 1.
Previous: Disabling, Up: Breakpoints [Contents][Index]