[Bug 252542] cmp -s + regular files + skipping is broken
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sat Jan 9 21:48:34 UTC 2021
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252542
Ed Maste <emaste at freebsd.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|New |In Progress
Assignee|bugs at FreeBSD.org |emaste at freebsd.org
--- Comment #1 from Ed Maste <emaste at freebsd.org> ---
In the man page,
-z For regular files compare file sizes first, and fail the
comparison if they are not equal.
so I think this is expected behaviour with -z; do you agree?
For -s this is certainly a bug; I'm considering this as a fix:
diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
index c762f1346abf..47f9b671985c 100644
--- a/usr.bin/cmp/cmp.c
+++ b/usr.bin/cmp/cmp.c
@@ -92,7 +92,6 @@ main(int argc, char *argv[])
break;
case 's': /* silent run */
sflag = true;
- zflag = true;
break;
case 'x': /* hex output */
lflag = true;
@@ -149,6 +148,9 @@ main(int argc, char *argv[])
skip1 = argc > 2 ? strtol(argv[2], NULL, 0) : 0;
skip2 = argc == 4 ? strtol(argv[3], NULL, 0) : 0;
+ if (sflag && skip1 == 0 && skip2 == 0)
+ zflag = true;
+
if (fd1 == -1) {
if (fd2 == -1) {
c_link(file1, skip1, file2, skip2);
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list