aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/diff/diff.c
diff options
context:
space:
mode:
authorJamie Landeg-Jones <jamie@catflap.org>2021-01-25 17:42:26 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2021-01-25 19:38:18 +0000
commitfefb3c46a80fdde6f307e73a2b5b5aed806df1ce (patch)
treeafd4eeceb2db3f16cf65a6300c23f443f3209091 /usr.bin/diff/diff.c
parent13860e71eb501f498a2263f44ea9244f6830b61c (diff)
diff: fix incorrectly displaying files as duplicates
When diff hits certain access errors, function diffreg() shows the error message, and then returns to the calling function, which calls print_status() with the return value. However, in these cases, the return value isn't changed from the initial default value of D_SAME. Normally, print_status() with a value of D_SAME does nothing, so this works out ok, however, if the "-s" flag is set, a message is displayed showing identicality: case D_SAME: if (sflag) printf("Files %s%s and %s%s are identical\n", path1, entry, path2, entry); break; This then produces such results as: % diff -s /COPYRIGHT /var/run/rpcbind.sock diff: /var/run/rpcbind.sock: Operation not supported Files /COPYRIGHT and /var/run/rpcbind.sock are identical % diff -s /COPYRIGHT /etc/master.passwd diff: /etc/master.passwd: Permission denied Files /COPYRIGHT and /etc/master.passwd are identical Create a D_ERROR status which is returned in such cases, and print_status() then deals with that status seperately from D_SAME PR: 252614 MFC after: 1 week
Diffstat (limited to 'usr.bin/diff/diff.c')
-rw-r--r--usr.bin/diff/diff.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c
index 0e46b96f9667..1bad6226f49d 100644
--- a/usr.bin/diff/diff.c
+++ b/usr.bin/diff/diff.c
@@ -511,6 +511,8 @@ print_status(int val, char *path1, char *path2, const char *entry)
printf("File %s%s is not a regular file or directory and was skipped\n",
path2, entry);
break;
+ case D_ERROR:
+ break;
}
}