--- orig/shell-tools
+++ mod/shell-tools
@@ -60,8 +60,15 @@
     if [ -n "${saved_traps}" ]; then
 	eval "${saved_traps}"
     else
-	# remove all traps by replacing them with a no-op trap
-	trap ':' EXIT
+	local traps=$(trap)
+	if [ -n "${traps}" ]; then
+	    local conditions=$(echo "${traps}" \
+		| sed --quiet --expression="s/^trap[[:space:]]\+--[[:space:]]\+'[^']\+'[[:space:]]\+\([^[:space:]]\+\)\$/\1/p")
+
+	    for condition in ${conditions}; do
+		trap - "${condition}"
+	    done
+	fi
     fi
 }
 
