forked from Proxmox/ProxmoxVE
fix(tools.func): remove dangerous trap in create_temp_dir()
The EXIT/ERR/INT/TERM trap inside create_temp_dir() overwrites any global traps and fires when the shell exits, not when the calling function returns. Since the function is a utility that returns a path via stdout, the trap fires immediately on function return and cannot properly clean up the caller's temp dir. Callers already handle their own cleanup via explicit rm -rf.
This commit is contained in:
@@ -1100,8 +1100,9 @@ get_system_arch() {
|
||||
# ------------------------------------------------------------------------------
|
||||
create_temp_dir() {
|
||||
local tmp_dir=$(mktemp -d)
|
||||
# Set trap to cleanup on EXIT, ERR, INT, TERM
|
||||
trap "rm -rf '$tmp_dir'" EXIT ERR INT TERM
|
||||
# Callers should handle their own cleanup (rm -rf "$tmpdir")
|
||||
# Do NOT set trap here — it would overwrite global traps and only fire
|
||||
# when create_temp_dir() itself returns, not the calling function
|
||||
echo "$tmp_dir"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user