Date: Sat, 09 Jan 2021 21:48:34 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 252542] cmp -s + regular files + skipping is broken Message-ID: <bug-252542-227-fP0T3oxR0L@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-252542-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252542 Ed Maste <emaste@freebsd.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|New |In Progress Assignee|bugs@FreeBSD.org |emaste@freebsd.org --- Comment #1 from Ed Maste <emaste@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.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-252542-227-fP0T3oxR0L>
