_lastrc - UDM Built-in Variable


The _lastrc built-in variable holds the UDM return code of the last UDM command issued.

_lastrc also has two special attributes: message and result.

message

Contains a human-readable string indicating what happened with the last executed statement.

  • If a command could not be executed or had improper values, the value of _lastrc.message is ERROR.
  • If a command successfully executed, the value of _lastrc.message is either SUCCESS or some other message (depending upon the command).

result

Holds an integer value that indicates the result of the last command executed.
 
The meaning of this value depends on the command. Unless otherwise stated:

  • -1 indicates failure.
  • 0 or a positive value indicates success.

This value does not affect the value of _rc and _lastrc.

_lastrc cannot be set using the set command.


A Stonebranch Tip

You can use _lastrc in combination with the if statement to take action based on the return value of the previously issued command:

copy src=myfile if $(_lastrc) EQ 0
      delete src=myfile
end