]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
rm: output number of arguments at the interactive prompt
authorRasmus Villemoes <rv@rasmusvillemoes.dk>
Thu, 18 Jul 2013 21:53:12 +0000 (21:53 +0000)
committerPádraig Brady <P@draigBrady.com>
Fri, 19 Jul 2013 11:27:09 +0000 (12:27 +0100)
Include the number of arguments which rm received in the "Remove all
arguments?" prompt.  This is useful in the, presumably, common case
where the arguments were not provided by hand, but instead were the
result of various shell expansions.  A simple, if somewhat contrived,
example (assuming rm is aliased to rm -I) could be:

  rm * .o

where the prompt "Remove 120 arguments?" is more likely to make
the user catch the problem.

* src/rm.c (main): Include correctly pluralized n_files
in the output message.  Also remove the now redudant "all".
* tests/rm/interactive-always.sh: Adjust to the new prompt.
* tests/rm/interactive-once.sh: Likewise.

src/rm.c
tests/rm/interactive-always.sh
tests/rm/interactive-once.sh

index 3e187cf80d5ecf3e7743662f8b0e9ee0b956c0ac..b9b84e1178a05c6d8017a605b40bf3a2d01bf8e1 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -339,9 +339,13 @@ main (int argc, char **argv)
     {
       fprintf (stderr,
                (x.recursive
-                ? _("%s: remove all arguments recursively? ")
-                : _("%s: remove all arguments? ")),
-               program_name);
+                ? ngettext ("%s: remove %zu argument recursively? ",
+                            "%s: remove %zu arguments recursively? ",
+                            select_plural (n_files))
+                : ngettext ("%s: remove %zu argument? ",
+                            "%s: remove %zu arguments? ",
+                            select_plural (n_files))),
+               program_name, n_files);
       if (!yesno ())
         exit (EXIT_SUCCESS);
     }
index 1dfb5a694dd5f9034ebf53f9f3b008b11d244936..13743eb497c200e36a22e9cbf290c8f775ac654b 100755 (executable)
@@ -72,13 +72,13 @@ no WHEN
 WHEN=never
 .
 WHEN=once
-rm: remove all arguments recursively? .
+rm: remove 2 arguments recursively? .
 WHEN=always
 @remove_empty 'file4-1'? @remove_empty 'file4-2'? .
 -f overrides --interactive
 .
 --interactive overrides -f
-rm: remove all arguments recursively? .
+rm: remove 1 argument recursively? .
 EOF
 
 compare expout out || fail=1
index d138b752085638ae085bda8d1db094d61737b7dd..dcda5b84827d5dbc93063209e1c061557b1a17c3 100755 (executable)
@@ -88,17 +88,17 @@ one file, no recursion
 three files, no recursion
 .
 four files, no recursion, answer no
-rm: remove all arguments? .
+rm: remove 4 arguments? .
 four files, no recursion, answer yes
-rm: remove all arguments? .
+rm: remove 4 arguments? .
 one file, recursion, answer no
-rm: remove all arguments recursively? .
+rm: remove 1 argument recursively? .
 one file, recursion, answer yes
-rm: remove all arguments recursively? .
+rm: remove 1 argument recursively? .
 multiple files, recursion, answer no
-rm: remove all arguments recursively? .
+rm: remove 2 arguments recursively? .
 multiple files, recursion, answer yes
-rm: remove all arguments recursively? .
+rm: remove 2 arguments recursively? .
 EOF
 
 compare expout out || fail=1