summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>1999-12-04 01:29:43 +0000
committerobrien <obrien@FreeBSD.org>1999-12-04 01:29:43 +0000
commitb6b57faeef807ca8b13a23e047d8479ab962044b (patch)
tree6eee565e226210d35d2874a1b94cdb99067b8e52 /sbin
parent27b8e11386a5c439de38b788b854c370bb42b9f2 (diff)
downloadFreeBSD-src-b6b57faeef807ca8b13a23e047d8479ab962044b.zip
FreeBSD-src-b6b57faeef807ca8b13a23e047d8479ab962044b.tar.gz
Add -q quite mode.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/md5/md5.16
-rw-r--r--sbin/md5/md5.c14
2 files changed, 16 insertions, 4 deletions
diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1
index c3c3e50..c485184 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 c20d659..9a764b1 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));
OpenPOWER on IntegriCloud