diff options
Diffstat (limited to 'tests/rm/r-4.sh')
-rwxr-xr-x | tests/rm/r-4.sh | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/tests/rm/r-4.sh b/tests/rm/r-4.sh index 94702a6d..095f1516 100755 --- a/tests/rm/r-4.sh +++ b/tests/rm/r-4.sh @@ -1,7 +1,7 @@ #!/bin/sh # Try to remove '.' and '..' recursively. -# Copyright (C) 2006-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2014 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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 |