diff --git a/src/md5sum.c b/src/md5sum.c index e58a68e..17cbde0 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -154,6 +154,9 @@ static bool quiet = false; improperly formatted. */ static bool strict = false; +/* With --digest-only show only the digest, not the filename */ +static bool digest_only = false; + /* Whether a BSD reversed format checksum is detected. */ static int bsd_reversed = -1; @@ -197,7 +200,8 @@ enum STATUS_OPTION, QUIET_OPTION, STRICT_OPTION, - TAG_OPTION + TAG_OPTION, + DIGEST_ONLY_OPTION }; static struct option const long_options[] = @@ -214,6 +218,7 @@ static struct option const long_options[] = { "warn", no_argument, NULL, 'w' }, { "strict", no_argument, NULL, STRICT_OPTION }, { "tag", no_argument, NULL, TAG_OPTION }, + { "digest-only", no_argument, NULL, DIGEST_ONLY_OPTION }, { GETOPT_HELP_OPTION_DECL }, { GETOPT_VERSION_OPTION_DECL }, { NULL, 0, NULL, 0 } @@ -541,6 +546,9 @@ hex_digits (unsigned char const *s) static void print_filename (char const *file, bool escape) { + if (digest_only) + return; + if (! escape) { fputs (file, stdout); @@ -931,6 +939,9 @@ main (int argc, char **argv) prefix_tag = true; binary = 1; break; + case DIGEST_ONLY_OPTION: + digest_only = true; + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: