From 26574d5284c71b893df1b63a1fe823d65b5a476c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 9 Aug 1995 02:50:09 +0000 Subject: (md5_check): Fail if no valid line is found. Don't use the word `fail' unless there were failures -- say `all N tests passed.' --- src/md5sum.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src/md5sum.c') diff --git a/src/md5sum.c b/src/md5sum.c index c3e7ab56b..48980b2f9 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -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 -- cgit v1.2.3-70-g09d2