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

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

Bug#146890: diff: cmp output different to documented behavior (fwd)


From: Santiago Vila
Subject: Bug#146890: diff: cmp output different to documented behavior (fwd)
Date: Sun, 26 May 2002 01:25:05 +0200 (CEST)

Hello.

I received the following report from the Debian bug system:

---------- Forwarded message ----------
Date: Tue, 14 May 2002 14:54:27 +1000
From: Steven Hanley <address@hidden>
To: Debian Bug Tracking System <address@hidden>
Subject: Bug#146890: diff: cmp output different to documented behavior

Package: diff
Version: 2.7-29
Severity: normal

The behavior of the cmp program in the diff package is different to what the
documentation implies.

When comparing two files, and one file is identical to the other up to a point
and then has data appended to it (like a log file or mail spool or similar)

The cmp documentation says

GNOSTICS
       The cmp utility exits with one of the following values:
       0      The files or byte ranges are identical.
       1      The files or byte ranges are different; this includes  the  case  
where  one
              file  or  range  is identical to the first part of the other.  In 
the latter
              case, if -s has not been specified, cmp writes to standard output 
 that  EOF
              was reached in the shorter file.
       >1     An error occurred.

the section

cmp writes to standard output that EOF was reached in the shorter file.

is incorrect, it does in fact write to stderr.

The version of cmp on other linux distributions has this same incorrect
behavior or incorrect man page. The man pages all claim cmp complies with
posix so I guess upstream should ensure they also comply.

An example of this behavior is

[14:45:46] 299 shiva sjh ~>dpkg -S /usr/bin/cmp
diff: /usr/bin/cmp
[14:45:52] 300 shiva sjh ~>cat > f1
a
[14:46:19] 301 shiva sjh ~>cat > f2
a
b
[14:46:23] 302 shiva sjh ~>cmp f1 f2 > fish
cmp: EOF on f1
[14:46:50] 303 shiva sjh ~>cat fish
[14:46:55] 304 shiva sjh ~>

This is an upstream bug, and does not really affect the use of the program
cmp, however the program or the man page documenting it should be corrected.
---------------------------------------

I asked the submitter whether or not this was still the case in
diffutils-2.7.10 (which is the last one I packaged for experimental)
and he confirmed that it was the case:

---------------------------------------

[...]
cs:~# diff --version | grep diff
diff (GNU diffutils) 2.7.10
cs:~# cat > f1
a
cs:~# cat > f2
a
b
cs:~# cmp f1 f2 > fish
cmp: EOF on f1
cs:~# cat fish
cs:~#

same behavior

however niether the man page, or the info documentation (which the man page
now points to as authorative documentation) mention the cmp: EOF stuff that is
expected behavior when files are identical to a point then one ends and the
other has more data appended.

So the behavior is still there however is now completely undocumented.

The solaris man page for cmp for example does not mention where the ourput is
directed but does say

If one file is an  initial subsequence of the other, that fact is noted.

in the description and

     1     The files are different; this includes the case  where
           one file is identical to the first part of the other.

In the exit status documentation.

The new diff package does not mentioned this behavior of cmp (for one file
being the initial subsequence of the other) at all in man or info
documentation now.

Personally I think it is important that the behavior be documented.

BTW the solaris version of cmp also outputs the cmp: EOF thing on
stderr. (although the man page on solaris does not specify which stream it
sends it to as the diff docs used to on linux.)




reply via email to

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