From dbf3fa6f1d092e2f31c714ac8cb3a30bb7a2474a Mon Sep 17 00:00:00 2001 From: MickLesk Date: Thu, 19 Mar 2026 20:26:38 +0100 Subject: [PATCH] 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. --- misc/tools.func | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/misc/tools.func b/misc/tools.func index 9856681d8..ed85a0f64 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -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" }