summaryrefslogtreecommitdiff
path: root/usr.bin/diff/diffdir.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2017-08-28 15:33:28 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2017-08-28 15:33:28 +0000
commit6d90813bf3d4336f3813c7363f43d43619132701 (patch)
treea2b387f34560531fbb305da69f814f9f2d7b4293 /usr.bin/diff/diffdir.c
parent5a31c1921922406134a885c582fa4e8bed909f3f (diff)
Fix exit value when diffing directories with missing files and the -N
or -P options are not used. From Ibrahim Khalifa
Diffstat (limited to 'usr.bin/diff/diffdir.c')
-rw-r--r--usr.bin/diff/diffdir.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c
index 3b817f1a2c6..758332b04ce 100644
--- a/usr.bin/diff/diffdir.c
+++ b/usr.bin/diff/diffdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffdir.c,v 1.45 2015/10/05 20:15:00 millert Exp $ */
+/* $OpenBSD: diffdir.c,v 1.46 2017/08/28 15:33:27 millert Exp $ */
/*
* Copyright (c) 2003, 2010 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -57,7 +57,7 @@ diffdir(char *p1, char *p2, int flags)
dirlen1 = strlcpy(path1, *p1 ? p1 : ".", sizeof(path1));
if (dirlen1 >= sizeof(path1) - 1) {
warnc(ENAMETOOLONG, "%s", p1);
- status = 2;
+ status |= 2;
return;
}
if (path1[dirlen1 - 1] != '/') {
@@ -67,7 +67,7 @@ diffdir(char *p1, char *p2, int flags)
dirlen2 = strlcpy(path2, *p2 ? p2 : ".", sizeof(path2));
if (dirlen2 >= sizeof(path2) - 1) {
warnc(ENAMETOOLONG, "%s", p2);
- status = 2;
+ status |= 2;
return;
}
if (path2[dirlen2 - 1] != '/') {
@@ -129,19 +129,23 @@ diffdir(char *p1, char *p2, int flags)
dp2++;
} else if (pos < 0) {
/* file only in first dir, only diff if -N */
- if (Nflag)
+ if (Nflag) {
diffit(dent1, path1, dirlen1, path2, dirlen2,
flags);
- else
+ } else {
print_only(path1, dirlen1, dent1->d_name);
+ status |= 1;
+ }
dp1++;
} else {
/* file only in second dir, only diff if -N or -P */
- if (Nflag || Pflag)
+ if (Nflag || Pflag) {
diffit(dent2, path1, dirlen1, path2, dirlen2,
flags);
- else
+ } else {
print_only(path2, dirlen2, dent2->d_name);
+ status |= 1;
+ }
dp2++;
}
}