Skip to contentSkip to conversation

tests: remove temporary file

PATCH In review Florian Westphal 2 participants 2 messages Mar 4, 2025 – Mar 5, 2025 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 tests: remove temporary file

0002-relative leaves a temporary file in the current working directory, at the time the "trap" argument is expanded, tmpfile2 isn't set.

---
 tests/shell/testcases/include/0002relative_0 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tests/shell/testcases/include/0002relative_0 +7 -2
index dbf11e7db171..ac8355475320 100755
@@ -7,9 +7,14 @@ if [ ! -w "$tmpfile1" ] ; then
 	exit 77
 fi
 
-trap "rm -rf $tmpfile1 $tmpfile2" EXIT # cleanup if aborted
-set -e
+cleanup()
+{
+	rm -f "$tmpfile1" "$tmpfile2"
+}
+
+trap cleanup EXIT
 
+set -e
 tmpfile2=$(mktemp -p .)
 
 RULESET1="add table x"
Signature · 1 line
2.48.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Florian Westphal

0002-relative leaves a temporary file in the current working directory, at the time the "trap" argument is expanded, tmpfile2 isn't set.

Quoted 29 lines
---
 tests/shell/testcases/include/0002relative_0 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tests/shell/testcases/include/0002relative_0 +7 -2
index dbf11e7db171..ac8355475320 100755
@@ -7,9 +7,14 @@ if [ ! -w "$tmpfile1" ] ; then
 	exit 77
 fi
 
-trap "rm -rf $tmpfile1 $tmpfile2" EXIT # cleanup if aborted
-set -e
+cleanup()
+{
+	rm -f "$tmpfile1" "$tmpfile2"
+}
+
+trap cleanup EXIT
 
+set -e
 tmpfile2=$(mktemp -p .)
 
 RULESET1="add table x"
Signature · 1 line
2.48.1