Programmer Guide/Command Reference/EXIT: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==EXIT==
What the various flavours of the <code>EXIT</code> statement have in common is that they all terminate something.


<code>EXIT 0</code>
EXIT 0
This will terminate the shell immediately (which also implies that no result assignment is possible).


Terminate the shell immediately (no result assignment possible).
EXIT <var>'''–'''level</var> <var>result_expression</var>
This will return from as many macro levels as needed to find a macro level where there is a non-empty local variable <var>#onexitall</var> defined.


<code>EXIT <var>–level</var> <var>result_expression</var></code>
EXIT <var>level</var> <var>result_expression</var>
This will return from <var>level</var> macro levels, and assign <var>result_expression</var> to the shell variable <code>RESULT</code>. The most common form is <code>EXIT 1 <var>result_expression</var></code>, in which case only one (1) macro level will be left, causing control flow to return to the calling macro.


Return to the first macro with a local variable <code>#onexitall</code> that is not empty.
EXIT
 
The naked <code>EXIT</code> statement will return to the calling macro, i.e., leave one macro level, making the statement, with this respect, equivalent to <code>EXIT 1</code>. The naked <code>EXIT</code> statement does not set the <code>RESULT</code> variable.
Pre S_TOOLS-STx 3.9: this function returns to macro with variable <code>#EXITLEVEL</code> equals <var>level</var> and assign <var>result_expression</var> to variable <code>RESULT</code>.
 
<code>EXIT <var>level</var> <var>result_expression</var></code>
 
Return from <var>level</var> Macros (e.g. 1 = returns to the calling macro) and assign <var>result_expression</var> to the shell variable <code>RESULT</code>.
 
<code>EXIT</code>
 
Returns to the calling macro (1 level). The variable <code>RESULT</code> is not set.


See the script <code>exitlevels.sts</code> for a working example.
See the script <code>exitlevels.sts</code> for a working example.
<!-- C.G. 23.3.2011 -->

Revision as of 19:38, 23 March 2011

What the various flavours of the EXIT statement have in common is that they all terminate something.

EXIT 0

This will terminate the shell immediately (which also implies that no result assignment is possible).

EXIT level result_expression

This will return from as many macro levels as needed to find a macro level where there is a non-empty local variable #onexitall defined.

EXIT level result_expression

This will return from level macro levels, and assign result_expression to the shell variable RESULT. The most common form is EXIT 1 result_expression, in which case only one (1) macro level will be left, causing control flow to return to the calling macro.

EXIT

The naked EXIT statement will return to the calling macro, i.e., leave one macro level, making the statement, with this respect, equivalent to EXIT 1. The naked EXIT statement does not set the RESULT variable.

See the script exitlevels.sts for a working example.

Navigation menu

Personal tools