summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS6
-rw-r--r--src/rm.c3
-rwxr-xr-xtests/rm/r-root.sh9
3 files changed, 16 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index c3554d0fe..e68de05a2 100644
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,8 @@ GNU coreutils NEWS -*- outline -*-
** Changes in behavior
+ rm no longer accepts shortened variants of the --no-preserve-root option.
+
seq no longer accepts 0 value as increment, and now also rejects NaN
values for any argument.
@@ -81,8 +83,8 @@ GNU coreutils NEWS -*- outline -*-
** New Features
- date now accepts the --debug option, to annotate the parsed date string,
- display timezone information, and warn about potential misuse.
+ date now accepts the --debug option, to annotate the parsed date string,
+ display timezone information, and warn about potential misuse.
* Noteworthy changes in release 8.25 (2016-01-20) [stable]
diff --git a/src/rm.c b/src/rm.c
index 13a5714c3..2c54405f7 100644
--- a/src/rm.c
+++ b/src/rm.c
@@ -287,6 +287,9 @@ main (int argc, char **argv)
break;
case NO_PRESERVE_ROOT:
+ if (! STREQ (argv[optind - 1], "--no-preserve-root"))
+ error (EXIT_FAILURE, 0,
+ _("you may not abbreviate the --no-preserve-root option"));
preserve_root = false;
break;
diff --git a/tests/rm/r-root.sh b/tests/rm/r-root.sh
index b98db141b..3b7837fe0 100755
--- a/tests/rm/r-root.sh
+++ b/tests/rm/r-root.sh
@@ -211,6 +211,15 @@ for opts in \
done
#-------------------------------------------------------------------------------
+# Exercise with --no-preserve to ensure shortened equivalent is not allowed.
+cat <<EOD > exp_opt || framework_failure_
+rm: you may not abbreviate the --no-preserve-root option
+EOD
+returns_ 1 exercise_rm_r_root --no-preserve / || fail=1
+compare exp_opt err || fail=1
+test -f x && fail=1
+
+#-------------------------------------------------------------------------------
# Exercise "rm -r file1 / file2".
# Expect a non-Zero exit status representing failure to remove "/",
# yet 'file1' and 'file2' should be removed.