Note the use of single quotes, not double quotes.
That creates files named xaa.xz, xab.xz and xac.xz.
+ md5sum accepts the new --strict option. With --check, it makes the
+ tool exit non-zero for any invalid input line, rather than just warning.
+ This also affects sha1sum, sha224sum, sha384sum and sha512sum.
+
** Improvements
shuf outputs small subsets of large permutations much more efficiently.
/* With --check, suppress the "OK" printed for each verified file. */
static bool quiet = false;
+/* With --check, exit with a non-zero return code if any line is
+ improperly formatted. */
+static bool strict = false;
+
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
STATUS_OPTION = CHAR_MAX + 1,
- QUIET_OPTION
+ QUIET_OPTION,
+ STRICT_OPTION
};
static struct option const long_options[] =
{ "status", no_argument, NULL, STATUS_OPTION },
{ "text", no_argument, NULL, 't' },
{ "warn", no_argument, NULL, 'w' },
+ { "strict", no_argument, NULL, STRICT_OPTION },
{ GETOPT_HELP_OPTION_DECL },
{ GETOPT_VERSION_OPTION_DECL },
{ NULL, 0, NULL, 0 }
-w, --warn warn about improperly formatted checksum lines\n\
\n\
"), stdout);
+ fputs (_("\
+ --strict with --check, exit non-zero for any invalid input\n\
+"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\
FILE *checkfile_stream;
uintmax_t n_misformatted_lines = 0;
uintmax_t n_properly_formatted_lines = 0;
+ uintmax_t n_improperly_formatted_lines = 0;
uintmax_t n_mismatched_checksums = 0;
uintmax_t n_open_or_read_failures = 0;
unsigned char bin_buffer_unaligned[DIGEST_BIN_BYTES + DIGEST_ALIGN];
checkfile_name, line_number,
DIGEST_TYPE_STRING);
}
+
+ ++n_improperly_formatted_lines;
}
else
{
return (n_properly_formatted_lines != 0
&& n_mismatched_checksums == 0
- && n_open_or_read_failures == 0);
+ && n_open_or_read_failures == 0
+ && (!strict || n_improperly_formatted_lines == 0));
}
int
warn = false;
quiet = true;
break;
+ case STRICT_OPTION:
+ strict = true;
+ break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
usage (EXIT_FAILURE);
}
+ if (strict & !do_check)
+ {
+ error (0, 0,
+ _("the --strict option is meaningful only when verifying checksums"));
+ usage (EXIT_FAILURE);
+ }
+
if (!O_BINARY && binary < 0)
binary = 0;