aboutsummaryrefslogtreecommitdiff
path: root/sbin/md5
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>1999-12-04 01:29:43 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>1999-12-04 01:29:43 +0000
commit2963da13bf7b5df4a358a2a9b10e4721bf375cdd (patch)
tree4e574e32cde6f13d156656cd745fbd8186060f13 /sbin/md5
parentee7f6d9f9bd3c38246b0bd4fffc96f893fb177f5 (diff)
downloadsrc-2963da13bf7b5df4a358a2a9b10e4721bf375cdd.tar.gz
src-2963da13bf7b5df4a358a2a9b10e4721bf375cdd.zip
Add -q quite mode.
Notes
Notes: svn path=/head/; revision=54109
Diffstat (limited to 'sbin/md5')
-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 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));