svn commit: r321078 - head/usr.bin/diff

Ngie Cooper ngie at FreeBSD.org
Mon Jul 17 18:06:43 UTC 2017


Author: ngie
Date: Mon Jul 17 18:06:42 2017
New Revision: 321078
URL: https://svnweb.freebsd.org/changeset/base/321078

Log:
  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

Modified:
  head/usr.bin/diff/diffdir.c

Modified: head/usr.bin/diff/diffdir.c
==============================================================================
--- head/usr.bin/diff/diffdir.c	Mon Jul 17 17:50:50 2017	(r321077)
+++ head/usr.bin/diff/diffdir.c	Mon Jul 17 18:06:42 2017	(r321078)
@@ -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++;
 		}
 	}


More information about the svn-src-all mailing list