Date: Wed, 20 Jun 2012 20:00:28 GMT From: Garrett Cooper <yanegomi@gmail.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/169274: [patch] diff exit code always reports "trouble" when there are differences between 2 files Message-ID: <201206202000.q5KK0SUV027523@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/169274; it has been noted by GNATS. From: Garrett Cooper <yanegomi@gmail.com> To: Xin LI <delphij@gmail.com> 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:57:28 -0700 On Wed, Jun 20, 2012 at 12:44 PM, Garrett Cooper <yanegomi@gmail.com> wrote= : > On Wed, Jun 20, 2012 at 12:34 PM, Garrett Cooper <yanegomi@gmail.com> wro= te: >> On Wed, Jun 20, 2012 at 12:13 PM, Xin LI <delphij@gmail.com> wrote: >>>> $ 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. =A0It's not clear to me whether this is a bug or a >>> feature, as our diff(1) does not have a RETURN VALUE section. >> >> This is what I was referring to: >> >> =A0 =A0 =A0 FILES =A0are =A0`FILE1 =A0FILE2' =A0or `DIR1 DIR2' or `DIR F= ILE...' or `FILE... >> =A0 =A0 =A0 DIR'. =A0If --from-file or --to-file is given, there are no = =A0restrictions >> =A0 =A0 =A0 on =A0FILES. =A0If a FILE is `-', read standard input. =A0Ex= it status is 0 if >> =A0 =A0 =A0 inputs are the same, 1 if different, 2 if trouble. >> >> The definition of "trouble" here is unnecessarily ambiguous. I >> interpret trouble to be: >> 1. open failure. >> 2. stat failure. >> 3. read failure. >> etc. >> >> Comparing a binary file and text file does not constitute "trouble" -- >> they're just different. >> >> It concerns me because there's a fine line -- in some cases -- between >> binary and text files, depending on the content in the file (I'm >> thinking of .shar files for instance or uuencoded scripts). >> >>> With your proposed change, diff no longer distinguishes "trouble output= ting >>> 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. >> >> Ok. That was the difference (binary vs text): >> >> $ file valid.output unittest.dip >> valid.output: ASCII text >> unittest.dip: data >> >> Where is that requirement mentioned in the manpage though? I can't >> find it in the GNU diffutils manpage. >> >> If this is a BSD diff requirement, then it's doing something clearly >> different from GNU diff implementation. Whether or not the BSD >> implementation has to conform is another thing entirely, but it would >> be nice to keep the inconsistencies down to a minimum if at all >> possible. > > Classic Garrett and screwing up context -- there's only one diff in > base and it's GNU diff. Oh cool -- I forgot that GNU projects don't have useful manpages. The infopage concurs with what you said ( http://www.gnu.org/software/diffutils/manual/diffutils.html#Binary ): Normally, differing binary files count as trouble because the resulting diff output does not capture all the differences. This trouble causes diff to exit with status 2. However, this trouble cannot occur with the --text (-a) option, or with the --brief (-q) option, as these options both cause diff to generate a form of output that represents differences as requested. Please close this PR (-_-). Thanks, -Garrett
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206202000.q5KK0SUV027523>