SHTK_CLEANUP_REGISTER(3)
π NAME π
SHTK_CLEANUP_REGISTER(3) is the Library Functions Manual page for shtk_cleanup_register β it installs cleanup handlers to be called on script termination. No cap, that's the whole name-section moment. π«Ά
π LIBRARY π
Pull it in with:
shtk_import cleanup
β¨ SYNOPSIS β¨
shtk_cleanup_register handler1 [.. handlerN]
πΈ DESCRIPTION πΈ
okay so shtk_cleanup_register installs one or more cleanup handlers, and you hand them over as function names using the handler1 to handlerN arguments. One handler? slay. A whole lineup? also slay. β¨
The registered handlers get executed in the order they are originally registered β first registered, first called, iykyk. π₯
Registration of handlers is idempotent. That's the whole note. π
π¦ EXAMPLES π¦
Here's the example vibe: it creates a temporary file and installs a cleanup handler to make sure that 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 ALSO π
π HISTORY π
shtk_cleanup_register first appeared in shtk 1.4. Iconic behavior since day one, fr fr. π
That's the page, bestie: brought to you by Debian and dated November 5, 2014, with the manual tag SHTK_CLEANUP_REGISTER(3) doing its main character thing. ππ
π¦ where this page comes from
- nixos 26.05: shtk 1.7
- nixpkgs unstable: shtk 1.7
- Copyright 2014 Google Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms