From 2d920b13cbf3fe93b5ed2c4aa4254d24c0fc95bb Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 17 Jul 2017 18:06:42 +0000 Subject: 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 --- usr.bin/diff/diffdir.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'usr.bin/diff/diffdir.c') diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c index 1475e825e2dc..a022bffc1150 100644 --- a/usr.bin/diff/diffdir.c +++ b/usr.bin/diff/diffdir.c @@ -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++; } } -- cgit v1.2.3