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.
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.
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.
Remove the, previously registered, handler command associated to id. If no handler is associated to it: nothing happens.
Run all the registered handlers, from the last registered to the first. Whenever a handler is run: it is removed from the internal registry.
Remove all the registered handlers from the internal registry. This renders invalid all the handler identifiers that were created.