Add -q quite mode.
This commit is contained in:
parent
ee7f6d9f9b
commit
2963da13bf
@ -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
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user