From owner-freebsd-bugs@FreeBSD.ORG Wed Jun 20 19:20:15 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 042BE106564A for ; Wed, 20 Jun 2012 19:20:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3AAD18FC23 for ; Wed, 20 Jun 2012 19:20:14 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q5KJKEai091115 for ; Wed, 20 Jun 2012 19:20:14 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q5KJKEUD091114; Wed, 20 Jun 2012 19:20:14 GMT (envelope-from gnats) Date: Wed, 20 Jun 2012 19:20:14 GMT Message-Id: <201206201920.q5KJKEUD091114@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Xin LI Cc: Subject: Re: bin/169274: [patch] diff exit code always reports "trouble" when there are differences between 2 files X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Xin LI List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 19:20:15 -0000 The following reply was made to PR bin/169274; it has been noted by GNATS. From: Xin LI To: Garrett Cooper Cc: freebsd-gnats-submit@freebsd.org Subject: Re: bin/169274: [patch] diff exit code always reports "trouble" when there are differences between 2 files Date: Wed, 20 Jun 2012 12:13:31 -0700 > $ diff valid.output unittest.dip >/dev/null > $ echo $? > 2 I tried a few possible permutations and got expected result (when file is not accessible I got 2, and otherwise 1), except the case that one file is binary. It's not clear to me whether this is a bug or a feature, as our diff(1) does not have a RETURN VALUE section. With your proposed change, diff no longer distinguishes "trouble outputting the diff because at least one file is binary and you don't know it" and "I know it's binary (--brief) or I know what I am doing (--text), just let me know if there is difference", which sounds like a regression IMHO. > The patch attached fixes this logic error and another inconsistency with = "magic numbers": As a rule, cosmetic changes like change in the second one should never be applied on contributed code unless they are really broken. If for a BSD licensed diff maintained by ourselves this would be a desirable change. > $ diff -q /usr/src/contrib/diff/src/diff.c =C2=A0/usr/src/contrib/diff/sr= c/diff.c ; echo $? > 0 This is expected. > $ diff -q /usr/src/contrib/diff/src/diff.c =C2=A0/usr/src/contrib/diff/sr= c/diff.h ; echo $? > Files /usr/src/contrib/diff/src/diff.c and /usr/src/contrib/diff/src/diff= .h differ > 1 This is expected. > $ diff -q /usr/src/contrib/diff/src/diff.c =C2=A0/usr/src/contrib/diff/sr= c/diff.c~ ; echo $? > diff: /usr/src/contrib/diff/src/diff.c~: No such file or directory > 2 This is expected. > $ diff -N /usr/src/contrib/diff/src/diff.c /usr/src/contrib/diff/src/diff= .c~ >/dev/null; echo $? > 1 This is expected. What's wrong here? >>How-To-Repeat: > diff /usr/src/contrib/diff/src/diff.c =C2=A0/usr/src/contrib/diff/src/dif= f.h >/dev/null > ec=3D$? > if [ $ec -eq 1 ] > then > =C2=A0 =C2=A0echo PASS > else > =C2=A0 =C2=A0echo FAIL > fi I got "PASS" here... Cheers, --=20 Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die