Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

At times, it is useful to be able to exit from processing a single script file in the middle of that script file if certain processing conditions are not correct. For this, UDM provides the return command, which takes the following format:

<pre>
return [value]
</pre>
Panel
Html bobswift


The return command stops processing of the current script and returns control to the calling script at the point immediately following the script call (just as if the script had executed completely without calling the return command). If there was not a calling script, and UDM is not running interactively, UDM will exit. The return command also can be followed by an optional value. If this is the case, the UDM return code (held by the _rc built-in variable) is set to this value upon executing the return command.

...

Tip
titleA Stonebranch Tip

One common use of the return command is to exit from a script if the previous operation failed.

(The _halton built-invariable can be used for this situation if you want to exit from UDM altogether.)

However, if you only want to exit the current script, you can couple the return command with an if statement and the _lastrc] built-in variable:

if $(_lastrc) NE 0
       return $(_lastrc)
end

...