summaryrefslogtreecommitdiff
path: root/src/md5sum.c
diff options
context:
space:
mode:
authorErik Auerswald <auerswal@unix-ag.uni-kl.de>2008-06-01 12:40:40 +0200
committerJim Meyering <meyering@redhat.com>2008-06-01 16:55:11 +0200
commit86535835fe2c1fb73f0eeed4b2b1f1d95987272b (patch)
tree98352655a0ddb2e34417e4f01ab9f5a02bfb1e68 /src/md5sum.c
parent01e6181965e1d60dd1ba483c18682d167a9c48a0 (diff)
downloadcoreutils-86535835fe2c1fb73f0eeed4b2b1f1d95987272b.tar.xz
md5sum: new option, --quiet, to suppress OK messages
sha1sum, sha224sum, sha384sum, and sha512sum accept it, too. * src/md5sum.c: add option --quiet to suppress OK messages * doc/coreutils.texi: document option --quiet * tests/misc/md5sum: add test for option --quiet * NEWS: mention new option --quiet for md5sum+sha*sum in "New features" section
Diffstat (limited to 'src/md5sum.c')
-rw-r--r--src/md5sum.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/md5sum.c b/src/md5sum.c
index df812b91b..c0b5ed571 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -117,6 +117,9 @@ static bool status_only = false;
improperly formatted checksum line. */
static bool warn = false;
+/* With --check, suppress the "OK" printed for each verified file. */
+static bool quiet = false;
+
/* The name this program was run with. */
char *program_name;
@@ -124,13 +127,15 @@ char *program_name;
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
- STATUS_OPTION = CHAR_MAX + 1
+ STATUS_OPTION = CHAR_MAX + 1,
+ QUIET_OPTION
};
static const struct option long_options[] =
{
{ "binary", no_argument, NULL, 'b' },
{ "check", no_argument, NULL, 'c' },
+ { "quiet", no_argument, NULL, QUIET_OPTION },
{ "status", no_argument, NULL, STATUS_OPTION },
{ "text", no_argument, NULL, 't' },
{ "warn", no_argument, NULL, 'w' },
@@ -177,7 +182,8 @@ With no FILE, or when FILE is -, read standard input.\n\
"), stdout);
fputs (_("\
\n\
-The following two options are useful only when verifying checksums:\n\
+The following three options are useful only when verifying checksums:\n\
+ --quiet don't print OK for each successfully verified file\n\
--status don't output anything, status code shows success\n\
-w, --warn warn about improperly formatted checksum lines\n\
\n\
@@ -530,8 +536,10 @@ digest_check (const char *checkfile_name)
if (!status_only)
{
- printf ("%s: %s\n", filename,
- (cnt != digest_bin_bytes ? _("FAILED") : _("OK")));
+ if (cnt != digest_bin_bytes)
+ printf ("%s: %s\n", filename, _("FAILED"));
+ else if (!quiet)
+ printf ("%s: %s\n", filename, _("OK"));
fflush (stdout);
}
}
@@ -624,6 +632,7 @@ main (int argc, char **argv)
case STATUS_OPTION:
status_only = true;
warn = false;
+ quiet = false;
break;
case 't':
binary = 0;
@@ -631,6 +640,12 @@ main (int argc, char **argv)
case 'w':
status_only = false;
warn = true;
+ quiet = false;
+ break;
+ case QUIET_OPTION:
+ status_only = false;
+ warn = false;
+ quiet = true;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -662,6 +677,13 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
+ if (quiet & !do_check)
+ {
+ error (0, 0,
+ _("the --quiet option is meaningful only when verifying checksums"));
+ usage (EXIT_FAILURE);
+ }
+
if (!O_BINARY && binary < 0)
binary = 0;