[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(no subject)
From: |
Erik Auerswald |
Subject: |
(no subject) |
Date: |
Sun, 13 Apr 2008 18:31:25 +0200 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
>From 0bd30949c1953fc5339fc5cf30cc2527d3e660d7 Mon Sep 17 00:00:00 2001
From: Erik Auerswald <address@hidden>
Date: Sun, 13 Apr 2008 18:12:11 +0200
Subject: [PATCH] md5sum+sha*sum: add option --quiet/-q to suppress OK messages
* src/md5sum.c: add option --quiet/-q to suppress OK messages
* doc/coreutils.texi: document option --quiet/-q
* tests/misc/md5sum: add test for option --quiet/-q
* NEWS: mention new option --quiet/-q for md5sum+sha*sum in "New
features" section
Signed-off-by: Erik Auerswald <address@hidden>
---
NEWS | 3 +++
doc/coreutils.texi | 11 +++++++++++
src/md5sum.c | 29 +++++++++++++++++++++++++----
tests/misc/md5sum | 8 ++++++++
4 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index e208b30..5a97f13 100644
--- a/NEWS
+++ b/NEWS
@@ -47,6 +47,9 @@ GNU coreutils NEWS -*-
outline -*-
** New features
+ md5sum and sha*sum now know an option --quiet/-q to suppress the
+ printing of 'OK' messages.
+
join now verifies that the inputs are in sorted order. This check can
be turned off with the --nocheck-order option.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 01c2f00..7bffd34 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -3287,6 +3287,17 @@ If all listed files are readable and are consistent with
the associated
MD5 checksums, exit successfully. Otherwise exit with a status code
indicating there was a failure.
address@hidden -q
address@hidden --quiet
address@hidden -q
address@hidden --quiet
address@hidden verifying MD5 checksums
+This option is useful only when verifying checksums.
+When verifying checksums, don't generate an 'OK' message per successfully
+checked file. Files that fail the verification are reported in the
+default one-line-per-file format. If any files failed verification,
+a warning summarizing any failures is printed to standard error.
+
@item -t
@itemx --text
@opindex -t
diff --git a/src/md5sum.c b/src/md5sum.c
index 28bde99..821a3ad 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -114,6 +114,9 @@ static bool status_only = false;
improperly formatted checksum line. */
static bool warn = false;
+/* With --quiet, don't print a message for successfully verified files */
+static bool quiet = false;
+
/* The name this program was run with. */
char *program_name;
@@ -131,6 +134,7 @@ static const struct option long_options[] =
{ "status", no_argument, NULL, STATUS_OPTION },
{ "text", no_argument, NULL, 't' },
{ "warn", no_argument, NULL, 'w' },
+ { "quiet", no_argument, NULL, 'q' },
{ GETOPT_HELP_OPTION_DECL },
{ GETOPT_VERSION_OPTION_DECL },
{ NULL, 0, NULL, 0 }
@@ -174,8 +178,9 @@ 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\
--status don't output anything, status code shows success\n\
+ -q, --quiet no output for successfully verified files\n\
-w, --warn warn about improperly formatted checksum lines\n\
\n\
"), stdout);
@@ -521,8 +526,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);
}
}
@@ -603,7 +610,7 @@ main (int argc, char **argv)
atexit (close_stdout);
- while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL)) != -1)
+ while ((opt = getopt_long (argc, argv, "bctwq", long_options, NULL)) != -1)
switch (opt)
{
case 'b':
@@ -615,6 +622,7 @@ main (int argc, char **argv)
case STATUS_OPTION:
status_only = true;
warn = false;
+ quiet = false;
break;
case 't':
binary = 0;
@@ -622,6 +630,12 @@ main (int argc, char **argv)
case 'w':
status_only = false;
warn = true;
+ quiet = false;
+ break;
+ case 'q':
+ status_only = false;
+ warn = false;
+ quiet = true;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -653,6 +667,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;
diff --git a/tests/misc/md5sum b/tests/misc/md5sum
index ca23d94..da58801 100755
--- a/tests/misc/md5sum
+++ b/tests/misc/md5sum
@@ -51,6 +51,14 @@ my @Tests =
{OUT=>"f: OK\n"}],
['check-2', '--check', '--status', {IN=>{'f.md5' => "$degenerate f\n"}},
{AUX=> {f=> 'foo'}}, {EXIT=> 1}],
+ ['check-3', '--check', '--quiet', {AUX=> {f=> ''}},
+ {IN=> {'f.md5' => "$degenerate f\n"}},
+ {OUT=>""}],
+ ['check-4', '--check', '--quiet', {IN=>{'f.md5' => "$degenerate f\n"}},
+ {AUX=> {f=> 'foo'}}, {OUT=>"f: FAILED\n"},
+ {ERR=>"md5sum: WARNING: 1 of 1 computed"
+ . " checksum did NOT match\n"},
+ {EXIT=> 1}],
# The sha1sum and md5sum drivers share a lot of code.
# Ensure that md5sum does *not* share the part that makes
# sha1sum accept BSD format.
--
1.5.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- (no subject),
Erik Auerswald <=