diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1 index c3c3e507688d..c485184cc440 100644 --- a/sbin/md5/md5.1 +++ b/sbin/md5/md5.1 @@ -7,7 +7,7 @@ .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS .Nm md5 -.Op Fl prtx +.Op Fl pqrtx .Op Fl s Ar string .Op Ar file ... .Sh DESCRIPTION @@ -38,6 +38,10 @@ Print a checksum of the given .Ar string . .It Fl p Echo stdin to stdout and appends the MD5 sum to stdout. +.It Fl q +Quiet mode - only the MD5 sum is printed out. Overrides the +.Fl r +option. .It Fl r Reverses the format of the output. This helps with visual diffs. Does nothing when combined with the diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index c20d65936e1d..9a764b120bee 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -38,6 +38,7 @@ static const char rcsid[] = #define TEST_BLOCK_LEN 10000 #define TEST_BLOCK_COUNT 100000 +int qflag; int rflag; static void MDString PROTO_LIST((char *)); @@ -65,11 +66,14 @@ main(argc, argv) char buf[33]; if (argc > 1) { - while ((ch = getopt(argc, argv, "ps:rtx")) != -1) { + while ((ch = getopt(argc, argv, "ps:qrtx")) != -1) { switch (ch) { case 'p': MDFilter(1); break; + case 'q': + qflag = 1; + break; case 'r': rflag = 1; break; @@ -91,7 +95,9 @@ main(argc, argv) if (!p) warn("%s", argv[optind]); else - if (rflag) + if (qflag) + printf("%s\n", p); + else if (rflag) printf("%s %s\n", p, argv[optind]); else printf("MD5 (%s) = %s\n", argv[optind], @@ -113,7 +119,9 @@ MDString(string) size_t len = strlen(string); char buf[33]; - if (rflag) + if (qflag) + printf("%s\n", MD5Data(string, len, buf)); + else if (rflag) printf("%s \"%s\"\n", MD5Data(string, len, buf), string); else printf("MD5 (\"%s\") = %s\n", string, MD5Data(string, len, buf));