6.1.5 Whether execution can be stopped at the elements of a job definition script
The table below shows whether execution can be stopped at each element of a job definition script. For the elements listed below at which execution can be stopped, you use a breakpoint or sequential execution to stop execution.
Element of a job definition script |
Description |
Whether stoppable |
---|---|---|
for statement |
Indicates a for statement. |
Y |
case statement |
Indicates a case statement. |
Y |
if statement |
Indicates an if statement. |
Y |
while statement |
Indicates a while statement. |
Y |
until statement |
Indicates an until statement. |
Y |
elif statement |
Indicates an elif statement. |
Y |
else statement |
Indicates an else statement. |
N |
case pattern statement |
Indicates a pattern statement specified in a case statement. This does not apply to the internal processing of the pattern statement. |
N |
Termination of a conditional statement |
Indicates the termination of a conditional statement, such as then for the if and elif statements or do for the for, while, and until statements. |
N |
Termination of a block |
Indicates the termination of a block, such as done for the for, while, and until statements, esac for the case statement, or fi for the if statement. |
N |
Start of function definition |
Indicates the start of a function definition. |
N |
End of function definition |
Indicates the end of a function definition. |
N |
Start of function execution |
Indicates that a function begins. |
Y |
End of function execution |
Indicates that a function ends. |
N |
Extended script command |
Indicates an extended script command beginning with #-adsh. |
Y |
Standard shell command |
Indicates a command provided by the shell. |
Y |
Extended shell command |
Indicates an extended shell command. |
Y |
External command |
Indicates an executable external command. |
Y |
Assignment and arithmetic operations |
Indicates an assignment or arithmetic operation. |
Y |
End of job definition script (EOF) |
Indicates the end of the main job definition script. |
Y |
Comment and space |
Indicates a comment or space. |
N |
- Legend:
Y: Execution can be stopped.
N: Execution cannot be stopped.
Notes:
Execution is not stopped at a command that is executed by another process.
Example:
1: funcA(){ 2: a=100 3: echo $a 4: } 5: funcA & 6: pwd
In this example job definition script, if the step command is executed while execution is stopped before funcA & at line 5, execution stops before pwd at line 6. Execution does not stop within the funcA function because its internal commands are executed by another process according to the specification of &.
Execution is not stopped at a command specified in an argument of a shell command.
In Windows, if you specify a command substitution in the argument of a shell command, you can stop execution once before the argument part is executed and again before the actual command is executed. You can also stop execution twice in this manner when you execute a command substitution as a command, rather than as an argument.
In UNIX, if you specify a command substitution in the argument of a shell command, you can stop execution once before the entire command is executed. The following shows examples.
Examples:
In Windows:
echo `pwd`
Execution can be stopped once before `pwd` is executed and once before echo executed.
`echo pwd`
Execution can be stopped twice before `echo pwd` is executed.
In UNIX:
echo `pwd`
Execution can be stopped once before echo `pwd` is executed.
`echo pwd`
Execution can be stopped once before `echo pwd` is executed.
If you specify an extended script command onto a continuation line, you can stop execution on each line. Note that the extended script command itself executes when the last continuation line is executed.
If you specify a command after an assignment operator delimited by a space, use the debugger's set command to set values in variables when execution is stopped at the first assignment operator. When execution is stopped at each command, the character string obtained after variables have been expanded is displayed as the command name.
A breakpoint cannot be set at the end of a job definition script (EOF). Note that execution can be stopped at the EOF by using a watchpoint or in sequential execution, as well as by receiving a stop signal.
Execution will not stop at a breakpoint while action of the trap shell command is running. In UNIX, note that execution can be stopped in such a case by using a watchpoint or in sequential execution, as well as by receiving a stop signal.
If the time command is executed with a function call specified in its argument and the stop evaluation condition is satisfied by a watchpoint or by receipt of a stop signal, execution stops before the first command following the time command that allows execution to be stopped.
If commands are grouped (executed in child processes), execution can be stopped at the location of the right parenthesis ()). The command group will not execute while execution is stopped at the right parenthesis. You set the breakpoint at the lines that contains the right parenthesis. If you attempt to set a breakpoint at a line that does not contain the right parenthesis, the breakpoint is set automatically at the line where the right parenthesis is located. The following shows an example.
Example:
1: (
Cannot be stopped.
2: pwd
Cannot be stopped.
3: date
Cannot be stopped.
4: )
Can be stopped.
If you group multiple commands by enclosing them in curly brackets ({}) and you specify their execution in separate processes by means such as adding an ampersand (&), specify the grouping on a single line in order to set a breakpoint. If the grouping is specified over multiple lines, execution cannot be stopped at breakpoints that might be set. The following shows an example.
Example:
Specifying on a single line
1: { pwd; date;} &
Execution cannot be stopped at the set breakpoints
1: echo "test" 2: {
Cannot be set or execution cannot be stopped. 3: pwd
Can be set, but execution cannot be stopped. 4: date
Can be set, but execution cannot be stopped. 5: } &
Cannot be set, but execution can be stopped.
In the above example, breakpoints can be set on lines 3 and 4, but execution cannot be stopped at those locations. Execution can actually be stopped on line 5. For example, if sequential execution is performed from the command immediately preceding the group of commands (in this example, echo on line 1), execution can be stopped on line 5. When execution is stopped at the location of the right curly bracket, the group of commands will not have executed yet.
If only a command substitution is specified as a command, execution can be stopped at the line containing the termination symbol for the command substitution. When execution is stopped at the location of the termination symbol, the command substitution will not have executed yet. You set a breakpoint at the lines that contains the termination symbol. If you attempt to set a breakpoint at a line that does not contain the termination symbol, the breakpoint is set automatically at the line where the termination symbol is located. The following shows examples.
Example 1:
1: $(
Cannot be stopped. 2: echo pwd
Cannot be stopped. 3: )
Can be stopped.
Example 2:
1: `echo pwd`
Can be stopped.
If you specify only a command substitution as a command or in the argument of the builtin, command, or time command and you want to stop execution before execution of the command immediately following the command substitution, make sure that the result of the command substitution is not NULL, spaces, or a comment.
If a group of commands connected by pipes is stopped while executing or a command running in the background is stopped, multiple consecutive prompt character strings (adshdb) might be displayed.