![]() |
![]()
| ![]() |
![]()
NAME
LIBRARYshtk_import cleanup SYNOPSIS
DESCRIPTIONThe The registered handlers are executed in the order they are originally registered. Registration of handlers is idempotent. EXAMPLESThe following example creates a temporary file and installs a cleanup handler to ensure that the file gets removed when the script terminates: local pattern="${TMPDIR:-/tmp}/my_program.XXXXXX" local temp_file="$(mktemp "${pattern}" 2>/dev/null)" [ -f "${temp_file}" ] || shtk_cli_error "Failed to create temporary file" eval "remove_temp_file() { rm -f '${temp_file}'; }" shtk_cleanup_register remove_temp_file SEE ALSOHISTORY
|