summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/rm/r-4.sh25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/rm/r-4.sh b/tests/rm/r-4.sh
index 94702a6d1..a3ceaf985 100755
--- a/tests/rm/r-4.sh
+++ b/tests/rm/r-4.sh
@@ -22,11 +22,26 @@ print_ver_ rm
mkdir d || framework_failure_
touch d/a || framework_failure_
-rm -fr d/. 2>/dev/null && fail=1
-rm -fr d/./ 2>/dev/null && fail=1
-rm -fr d/.//// 2>/dev/null && fail=1
-rm -fr d/.. 2>/dev/null && fail=1
-rm -fr d/../ 2>/dev/null && fail=1
+# Expected error diagnostic as grep pattern.
+exp="^rm: refusing to remove '\.' or '\.\.' directory: skipping '.*'\$"
+
+rmtest()
+{
+ # Try removing - expecting failure.
+ rm -fr "$1" 2> err && fail=1
+
+ # Ensure the expected error diagnostic is output.
+ grep "$exp" err || { cat err; fail=1; }
+
+ return $fail
+}
+
+rmtest 'd/.' || fail=1
+rmtest 'd/./' || fail=1
+rmtest 'd/.////' || fail=1
+rmtest 'd/..' || fail=1
+rmtest 'd/../' || fail=1
+
# This test is too dangerous -- if there's a bug you're wiped out!
# rm -fr / 2>/dev/null && fail=1