bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] Checking multiple .md5 files (updated to CVS)


From: Paul Eggert
Subject: Re: [patch] Checking multiple .md5 files (updated to CVS)
Date: Tue, 19 Jul 2005 00:37:55 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Shish <address@hidden> writes:

> The reasoning behind the patch is that some people (like myself) prefer
> to have one .md5 file per regular file in a directory rather than
> one .md5 file for the lot (easier to move files around, etc).

Thanks for explaining it.  I installed the following patch.  Can you
please check it over, to make sure that it does what you want and is
documented clearly?  Thanks.

2005-07-19  Paul Eggert  <address@hidden>

        * NEWS: md5sum --check now accepts multiple input files, and
        similarly for sha1sum.  Extension suggested by Chris Girling.
        * doc/coreutils.texi (md5sum invocation): --check now allows multiple
        FILE inputs.
        * src/md5sum.c (usage, main): Support this new usage.

Index: NEWS
===================================================================
RCS file: /fetish/cu/NEWS,v
retrieving revision 1.302
diff -p -u -r1.302 NEWS
--- NEWS        15 Jul 2005 21:54:38 -0000      1.302
+++ NEWS        19 Jul 2005 07:29:09 -0000
@@ -186,6 +186,8 @@ GNU coreutils NEWS                      
   ls no longer outputs an extra space between the mode and the link count
   when none of the listed files has an ACL.
 
+  md5sum --check now accepts multiple input files, and similarly for sha1sum.
+
   If stdin is a terminal, nohup now redirects it from /dev/null to
   prevent the command from tying up an OpenSSH session after you logout.
 
Index: doc/coreutils.texi
===================================================================
RCS file: /fetish/cu/doc/coreutils.texi,v
retrieving revision 1.273
diff -p -u -r1.273 coreutils.texi
--- doc/coreutils.texi  18 Jul 2005 07:51:32 -0000      1.273
+++ doc/coreutils.texi  19 Jul 2005 07:29:10 -0000
@@ -2983,11 +2983,10 @@ options}.
 If a @var{file} is specified as @samp{-} or if no files are given
 @command{md5sum} computes the checksum for the standard input.
 @command{md5sum} can also determine whether a file and checksum are
-consistent.  Synopses:
+consistent.  Synopsis:
 
 @example
 md5sum address@hidden@dots{} address@hidden@dots{}
-md5sum address@hidden@dots{} --check address@hidden
 @end example
 
 For each @var{file}, @samp{md5sum} outputs the MD5 checksum, a flag
@@ -3013,9 +3012,9 @@ for reading standard input when standard
 
 @item -c
 @itemx --check
-Read file names and checksum information from the single @var{file}
-(or from stdin if no @var{file} was specified) and report whether
-each named file and the corresponding checksum data are consistent.
+Read file names and checksum information (not data) from each
address@hidden (or from stdin if no @var{file} was specified) and report
+whether the checksums match the contents of the named files.
 The input to this mode of @command{md5sum} is usually the output of
 a prior, checksum-generating run of @samp{md5sum}.
 Each valid line of input consists of an MD5 checksum, a binary/text
Index: src/md5sum.c
===================================================================
RCS file: /fetish/cu/src/md5sum.c,v
retrieving revision 1.138
diff -p -u -r1.138 md5sum.c
--- src/md5sum.c        11 Jul 2005 18:29:44 -0000      1.138
+++ src/md5sum.c        19 Jul 2005 07:29:10 -0000
@@ -107,7 +107,6 @@ usage (int status)
     {
       printf (_("\
 Usage: %s [OPTION] [FILE]...\n\
-  or:  %s [OPTION] --check [FILE]\n\
 Print or check %s (%d-bit) checksums.\n\
 With no FILE, or when FILE is -, read standard input.\n\
 \n\
@@ -124,7 +123,7 @@ With no FILE, or when FILE is -, read st
   -b, --binary            read in binary mode\n\
 "), stdout);
       printf (_("\
-  -c, --check             check %s sums against given list\n"),
+  -c, --check             read %s sums from the FILEs and check them\n"),
              DIGEST_TYPE_STRING (algorithm));
       if (O_BINARY)
        fputs (_("\
@@ -613,27 +612,17 @@ main (int argc, char **argv)
       usage (EXIT_FAILURE);
     }
 
-  if (do_check)
-    {
-      if (optind + 1 < argc)
-       {
-         error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
-         fprintf (stderr, "%s\n",
-                  _("Only one operand may be specified when using --check."));
-         usage (EXIT_FAILURE);
-       }
+  if (optind == argc)
+    argv[argc++] = "-";
 
-      ok = digest_check (optind == argc ? "-" : argv[optind],
-                        DIGEST_STREAM (algorithm));
-    }
-  else
+  for (; optind < argc; ++optind)
     {
-      if (optind == argc)
-       argv[argc++] = "-";
+      char *file = argv[optind];
 
-      for (; optind < argc; ++optind)
+      if (do_check)
+       ok &= digest_check (file, DIGEST_STREAM (algorithm));
+      else
        {
-         char *file = argv[optind];
          int file_is_binary = binary;
 
          if (! digest_file (file, &file_is_binary, bin_buffer,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]