bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Should "diff" on binary files throw an exit code 2?


From: Philipp Marek
Subject: Should "diff" on binary files throw an exit code 2?
Date: Tue, 26 Jun 2007 21:40:09 +0200
User-agent: KMail/1.9.7

Hello everybody,


as the author of FSVS (http://fsvs.tigris.org/) I'm challenged with a problem, 
and hope you can help.

Please keep my CC'ed, I'm not subscribed.


FSVS is one of the callers of diff; it checks the exit code (as every Good 
Program should do :-).

According to the documentation
  "An exit status of 0 means no differences were found, 1 means some
   differences were found, and 2 means trouble."

So an exit status of 1 is simply ignored (as that's the expected result), but 
for 2 FSVS currently throws an error.

Now one of the users has stumbled upon the fact that binary files cause "diff" 
to return the same error code as some other unspecified error; see  
http://www.mail-archive.com/users%40fsvs.tigris.org/msg00184.html for the 
mail.


Now here is my problem:
1) I don't want to replicate the binary-ness check in FSVS, as that possibly
   means reading both files fully - which can take arbitrary long, and is soon
   after re-done by diff.
2) Always adding the "-a" switch is also not an option - for eg. mp3 files we
   don't want a diff printed, that would (at least) mess up the console.
3) Just ignoring the exit code seems to be another bad way ... I'd really like
   to see when "diff" has a problem.

AFAICT the best way would be to change "diff" to not return a 2 for binary 
files, but a 1. That's not a completely compatible change, but returning a 3 
or 0 doesn't really change the situation, or does it?


Please tell me other ideas, or what I can do to do that 'correctly'.


Thank you very much in advance!


Regards,

Phil


-- 
Versioning your /etc, /home or even your whole installation?
             Try fsvs (fsvs.tigris.org)!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]