Fix exit status with -rq when there is a file in one directory but not another,

i.e., when print_only is called.

Prior to this change, -rq was always returning 0. After this change it will
return 1 if there is a difference between two directories.

This fixes compatibility with GNU diff and unbreaks backwards compatibility
expectations.

Found when trying to extend diff_test:brief_format_test.

MFC after:	2 months
MFC with:	r321076, r321077
This commit is contained in:
ngie 2017-07-17 18:06:42 +00:00
parent fb55484ad5
commit 9de6ffe10b

View File

@ -134,16 +134,20 @@ diffdir(char *p1, char *p2, int flags)
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)
diffit(dent2, path1, dirlen1, path2, dirlen2,
flags);
else
else {
print_only(path2, dirlen2, dent2->d_name);
status = 1;
}
dp2++;
}
}