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

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

diff'ing binary files results in exit status 2


From: Scott Finneran
Subject: diff'ing binary files results in exit status 2
Date: Wed, 30 Jan 2002 13:41:00 +1100

Hello,

I have discovered what I believe to be a bug or at the very least
something that has changed in the code, but not the documentation.

The short version of the story is that a diff of 2 files where at least
one is binary (and they differ), results in an exit status of 2.
According to the doco, a value of 2 indicates "trouble", however it does
not elaborate on the meaning of "trouble". 

Previous versions of diff resulted in a exit status of 1 indicating that
the files do indeed differ. This behaviour seems quite intentional if
you refer to the source (from version 2.7.7):

****************************************************************
/* If CHANGES, briefly report that two files differed.
   Return 2 if trouble, CHANGES otherwise.  */
static int
briefly_report (int changes, struct file_data const filevec[])
{
  if (changes)
    {
      char const *label0 = file_label[0] ? file_label[0] :
filevec[0].name;
      char const *label1 = file_label[1] ? file_label[1] :
filevec[1].name;

      if (brief)
        message ("Files %s and %s differ\n", label0, label1);
      else
        {
          message ("Binary files %s and %s differ\n", label0, label1);
          changes = 2;
        }
    }

  return changes;
}
****************************************************************

Can someone please confirm whether this is considered to be a bug or
expected behaviour. Either way, I am happy to provide a patch.

Kind Regards,

Scott Finneran



reply via email to

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