This article will cover the syntax of the ‘exit script’ control script statement.
This is a statement that ends the execution. It can be used anywhere in the script to force a stop.
Statement syntax
Exit Script [ (when | unless) condition ]
When | Unless | If the script execution should only stop if certain conditions are met, the when/ unless clause can be used to achieve that. |
Condition | These are logical expressions that will be evaluated to decide whether to stop the execution. They must evaluate to True or False. |
Example
This is an example of a simple exit script statement.
Exit script;
Result
The result is that whenever an exit script statement is used, any subsequent code is not executed.