Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

UDM - if Statement - Returning Early Using the return Command

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:


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.


A 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

 

  • No labels