From 9e3972e7e7d8988a2c47fa116264e1c9f0aaef22 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 13 Mar 2014 22:41:41 +0100 Subject: [PATCH] Safe-guard for `rm -f /*` While looking at the source, I've seen this and imagined what might happen if some test causes unsetting of $TMP, or if the setup method would not be called for some reason. As a sidenote, I've wondered why BATS_TMPDIR is not used here. --- test/test_helper.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_helper.bash b/test/test_helper.bash index 9e10401..d504bc1 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -7,5 +7,7 @@ setup() { } teardown() { + # Safe guard, if $TMP might end up empty! + [[ -d "$TMP" ]] || { echo "FATAL: \$TMP is not a directory in teardown."; exit 1; } rm -f "$TMP"/* }