9.3.12 exit command (exits the shell)
Syntax
exit [n]
Description
This command exits the shell. Regardless of the value of the return code, this command terminates normally or with an error on the basis of whether the command syntax is valid.
If no argument is specified, the command terminates normally with the return code of the command that executed last as its return code. When executed with an appropriate numeric value specified for the argument, the command terminates normally. When executed with an invalid value, such as non-numeric characters, specified as the argument, the command terminates with an error. When the command terminates with an error, it returns 1 as the return code.
When this command is executed within a job step error block, the results are as follows:
If the argument is specified and the command terminates normally, the value specified in the argument is set as the job step's return code.
If the argument is not specified and the command terminates normally, or if it terminates with an error with the argument specified, the return code of the job step will be the return code of the last command to execute within the job step normal block.
Arguments
- n ~<unsigned integer>((0 to 255))
Specifies the return code to be set upon exiting the shell. If this argument is omitted, the command exits the shell with the return code of the last command that executed. If you specify 256 or a greater value for this argument, the command terminates normally with a return code that is the remainder of dividing the specified value by 256. If you specify a negative value for this argument, the command terminates normally with a return code that is the two's complement of the specified value.
Return codes
Return code |
Meaning |
---|---|
0 to 255 |
Normal termination
|
1 |
Error termination
|
Notes
You can specify for n a negative value or a value that is greater than 255, but we recommend that you specify in JP1/Advanced Shell a value in the range of 0 to 255.
If the command syntax of this special built-in command is invalid, it exits the shell that is executing the command.
When executing the exit command in a separate process, such as by using the & operator or a command substitution, also see the notes provided in 5.1.7 Execution as a separate process.
Example
Exit the shell with a return code of 2.
exit 2