{
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;
+ bool properly_formatted_lines = false;
+ bool matched_checksums = false;
unsigned char bin_buffer_unaligned[DIGEST_BIN_BYTES + DIGEST_ALIGN];
/* Make sure bin_buffer is properly aligned. */
unsigned char *bin_buffer = ptr_align (bin_buffer_unaligned, DIGEST_ALIGN);
to ease automatic processing of status output. */
bool needs_escape = ! status_only && strchr (filename, '\n');
- ++n_properly_formatted_lines;
+ properly_formatted_lines = true;
*bin_buffer = '\1'; /* flag set to 0 for ignored missing files. */
ok = digest_file (filename, &binary, bin_buffer);
}
if (cnt != digest_bin_bytes)
++n_mismatched_checksums;
+ else
+ matched_checksums = true;
if (!status_only)
{
return false;
}
- if (n_properly_formatted_lines == 0)
+ if (! properly_formatted_lines)
{
/* Warn if no tests are found. */
error (0, 0, _("%s: no properly formatted %s checksum lines found"),
"WARNING: %" PRIuMAX " computed checksums did NOT match",
select_plural (n_mismatched_checksums))),
n_mismatched_checksums);
+
+ if (ignore_missing && ! matched_checksums)
+ error (0, 0, _("%s: no file was verified"),
+ quotef (checkfile_name));
}
}
- return (n_properly_formatted_lines != 0
+ return (properly_formatted_lines
+ && matched_checksums
&& n_mismatched_checksums == 0
&& n_open_or_read_failures == 0
&& (!strict || n_improperly_formatted_lines == 0));
"meaningful only when verifying checksums\n".
$try_help},
{EXIT=> 1}],
+ ['check-ignore-missing-5', '--check', '--ignore-missing',
+ {AUX=> {f=> ''}},
+ {IN=> {'f.md5' => "$degenerate missing\n"}},
+ {ERR=>
+ "md5sum: f.md5: no file was verified\n"},
+ {EXIT=> 1}],
['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1},
{ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}],