Script ONEXIT Statement

ONEXIT block

ONEXIT is used to specify a set of statements to always execute before leaving a script.

The ONEXIT statement may be placed anywhere within a script. An ONEXIT block cannot contain a GOTO or RETURN statement.

When the script processor reaches an EXIT statement and an ONEXIT block has been defined, processing jumps to the ONEXIT block. After the ONEXIT block has been completed, the script ends. An EXIT statement within an ONEXIT block causes an immediate exit (the ONEXIT block is not executed again).

The block portion of the statement may be entered as one line, or as a set of statements between BEGIN and END.

For example, the statements:

  ECHO "These two lines will always be"
  ECHO "executed upon exiting the script."

cause the two lines to be displayed to the screen when you leave the script.

Copyright © 2017 American Chemical Society. All Rights Reserved.