test-lib.sh: add "atexit" functionality
authorTomi Ollila <tomi.ollila@iki.fi>
Tue, 23 May 2017 18:54:24 +0000 (21:54 +0300)
committerDavid Bremner <david@tethera.net>
Fri, 26 May 2017 10:25:55 +0000 (07:25 -0300)
commiteb157f8841b93a0df241b815e30ac54ca81cc83d
treed0865422441b7bb199018d1c6880fe10c6edc33b
parent523d2b50fcaae90cbe09975c1f1bc652ff521ec6
test-lib.sh: add "atexit" functionality

New function at_exit_function registers given function to be called
at script termination.

Functions so registered are called in the reverse order of their
registration; no arguments are passed.

Function is called only once; re-adding with function name already
registered will remove previous registration.

New function rm_exit_function can be used to remove registration.

Modules (and possibly test-lib.sh functions) in future commits will
register such functions.
test/test-lib.sh