Next: , Previous: , Up: Top   [Contents][Index]

20 Running scripts at exit–time

Bash allows us to execute a command whenever it exit by issuing the command:

trap <script> EXIT

the atexit MBFL module uses this mechanism to register, forget and run multiple commands.

Function: mbfl_atexit_enable
Function: mbfl_atexit_disable

Register or delete mbfl_atexit_run() as command for the EXIT event. We must call this function first if we want to use this module.

Function: mbfl_atexit_register handler
Function: mbfl_atexit_register handler idvar

Register a new handler command. If the optional argument idvar is present, it must be the name of a variable in the scope of the caller: store into such variable a unique identifier associated to the handler.

Function: mbfl_atexit_forget id

Remove the, previously registered, handler command associated to id. If no handler is associated to it: nothing happens.

Function: mbfl_atexit_run

Run all the registered handlers, from the last registered to the first. Whenever a handler is run: it is removed from the internal registry.

Function: mbfl_atexit_clear

Remove all the registered handlers from the internal registry. This renders invalid all the handler identifiers that were created.

Next: , Previous: , Up: Top   [Contents][Index]

This document describes version 3.0.0-devel.0 of Marcos Bash Functions Library.