[PATCH nft] tests: remove temporary file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
---
 tests/shell/testcases/include/0002relative_0 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tests/shell/testcases/include/0002relative_0 b/tests/shell/testcases/include/0002relative_0
index dbf11e7db171..ac8355475320 100755
--- a/tests/shell/testcases/include/0002relative_0
+++ b/tests/shell/testcases/include/0002relative_0
@@ -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"
-- 
2.48.1





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux