]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(md5_check): Fail if no valid line is found.
authorJim Meyering <jim@meyering.net>
Wed, 9 Aug 1995 02:50:09 +0000 (02:50 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 9 Aug 1995 02:50:09 +0000 (02:50 +0000)
Don't use the word `fail' unless there were failures --
say `all N tests passed.'

src/md5sum.c

index c3e7ab56b040d233cad3e0ad0f7ea845e2b0746c..48980b2f90d94aceff2a19eb332d49010e6dfbe8 100644 (file)
@@ -96,8 +96,8 @@ usage (status)
   else
     printf (_("\
 Usage: %s [OPTION] [FILE]...\n\
-  or:  %s [OPTION] --string=STRING\n\
   or:  %s [OPTION] --check [FILE]\n\
+  or:  %s [OPTION] --string=STRING ...\n\
 Print or check MD5 checksums.\n\
 With no FILE, or when FILE is -, read standard input.\n\
 \n\
@@ -341,14 +341,31 @@ md5_check (checkfile_name, binary)
       return 1;
     }
 
-  if (!quiet)
-    printf (n_tests == 1 ? (n_tests_failed ? _("Test failed\n")
-                                          : _("Test passed\n"))
-                        : _("%d out of %d tests failed\n"),
-           n_tests_failed, n_tests);
+  if (n_tests == 0)
+    {
+      /* FIXME: warn (or even fail?) if no tests are found?  */
+    }
+  else
+    {
+      if (!quiet)
+       {
+         if (n_tests_failed == 0)
+           {
+             printf (n_tests == 1
+                     ? _("the single test passed\n")
+                     : _("all %d tests passed\n"), n_tests);
+           }
+         else
+           {
+             printf (n_tests == 1
+                     ? _("the single test failed\n")
+                     : _("%d out of %d tests failed\n"),
+                     n_tests_failed, n_tests);
+           }
+       }
+    }
 
-  /* FIXME: warn if no tests are found?  */
-  return (n_tests_failed == 0 ? 0 : 1);
+  return ((n_tests > 0 && n_tests_failed == 0) ? 0 : 1);
 }
 
 int