aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2003-11-02 23:12:08 +0000
committerStefan Eßer <se@FreeBSD.org>2003-11-02 23:12:08 +0000
commit5758d949d56ba1c51ef18f59102dd96a1725d539 (patch)
treea0f58a3357cf1ce792edbc96da4eac1889f8aab5 /sbin
parent63f6cefcd53de45d4fa3d4e6495d09b46478335d (diff)
downloadsrc-5758d949d56ba1c51ef18f59102dd96a1725d539.tar.gz
src-5758d949d56ba1c51ef18f59102dd96a1725d539.zip
Set exit code to 1 in case at least one of the input files
could not be opened.
Notes
Notes: svn path=/head/; revision=121914
Diffstat (limited to 'sbin')
-rw-r--r--sbin/md5/md5.14
-rw-r--r--sbin/md5/md5.c11
2 files changed, 13 insertions, 2 deletions
diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1
index 2d5e8b0a2c36..de7b902410fa 100644
--- a/sbin/md5/md5.1
+++ b/sbin/md5/md5.1
@@ -67,6 +67,10 @@ Run a built-in time trial.
.It Fl x
Run a built-in test script.
.El
+.Sh DIAGNOSTICS
+The
+.Nm
+program exits 0 on success, and 1 if at least one of the input files could not be read.
.Sh SEE ALSO
.Xr cksum 1
.Rs
diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
index 5a33664a6cdf..9fd0cf8a3284 100644
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -62,7 +62,9 @@ main(int argc, char *argv[])
int ch;
char *p;
char buf[33];
+ int failed;
+ failed = 0;
while ((ch = getopt(argc, argv, "pqrs:tx")) != -1)
switch (ch) {
case 'p':
@@ -93,19 +95,24 @@ main(int argc, char *argv[])
if (*argv) {
do {
p = MD5File(*argv, buf);
- if (!p)
+ if (!p) {
warn("%s", *argv);
- else
+ failed++;
+ } else {
if (qflag)
printf("%s\n", p);
else if (rflag)
printf("%s %s\n", p, *argv);
else
printf("MD5 (%s) = %s\n", *argv, p);
+ }
} while (*++argv);
} else if (!sflag && (optind == 1 || qflag || rflag))
MDFilter(0);
+ if (failed != 0)
+ return (1);
+
return (0);
}
/*