Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


6.2.11 Terminating a function (return command)

The return command terminates commands. The return command returns control to the source of a function call without executing the lines following the current location in the function. The abbreviation for the return command is ret. The following shows the format of the return command:

return

The following describes the return command's processing.

When no argument is specified in the return command

When execution is stopped within a function, the command outputs a confirmation message asking whether the current function is to be terminated. To terminate the current function and return to the source of the function call, enter y or Y. The command displays the frame information for the source of the function call, the next line number scheduled to be executed, and the line in the source file. The following shows the display format for the frame information for the source of the function call.

Frame information for the source of the function call
Num  Function  File:Line
frame-number  function-name  file-name:line-number
  • frame-number: Indicates the frame number (0 is always displayed).

  • function-name: Indicates the name of the function corresponding to the frame information to which the name of the job definition script calling the function is attached. If no function has been called, <main> is displayed as the function name. A maximum of 6 bytes can be displayed.

  • file-name: Indicates the name of the file in which execution is currently stopped.

  • line-number: Indicates the line number at which execution is currently stopped.

    If execution is stopped at the end of the job definition script, <EOF> is displayed. If execution is stopped while the trap command's action is executing, <Trap action> is displayed.

If execution is stopped without having entered a function or if the job definition script is not running, the command outputs an error message.

When an argument is specified in the return command

Executing the command results in an error.

Notes:

The command terminates the function without stopping execution of the job definition script even if a stop evaluation condition is satisfied by a breakpoint, a watchpoint, or a signal on a subsequent line in the function.

Example

If the return command is executed while execution is stopped before echo on line 2, the command stops execution before echo on line 9 and displays the frame information. The command skips num=10 on line 3.

1: funcA(){
2:   echo "funcA"
3:   num=10
4: }
5:
6: val=1
7: num=2
8: funcA
9: echo $num
 
2:   echo "funcA"
Current: echo
(adshdb) return
KNAX7037-I Are you sure you want to exit the current function? (y or n)
y
KNAX7068-I Commands will be skipped until the end of the function.
...
Num  Function  File:Line
0    <main>    test.ash:9
KNAX7032-I The script "test.ash" stopped running.
9: echo $num
Current: echo
(adshdb)