atexit.sh 590 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

# LECA Bash library
#
# The LECA bash library provides a set of function used for helping
# development of bash script mainly to write job script on the luke
# cluster
#
# The files from the LECA Bash library must be sourced from your main script
#
#

include logging
logdebug "Load atexit package"

include stacks
newstack __LECABASHLIB_ATEXITSTACK__


function __atexit__manager__() {
	echo coucou
	while popvalue __LECABASHLIB_ATEXITSTACK__ cmd ; do
		eval "$cmd"
	done
}

function registeratexit() {
27
	pushvalue __LECABASHLIB_ATEXITSTACK__ "${*}"
28 29 30
}

trap "__atexit__manager__" EXIT ERR