[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: diff: incorrect and undocumented cmp output when stdout is redirecte
From: |
Vincent Lefevre |
Subject: |
Re: diff: incorrect and undocumented cmp output when stdout is redirected |
Date: |
Thu, 9 Mar 2006 18:00:48 +0100 |
User-agent: |
Mutt/1.5.11-vl-20060309 |
[Cc to bug-gnu-utils]
On 2006-03-09 17:29:38 +0100, Vincent Lefevre wrote:
> Package: diff
> Version: 2.8.1-11
> Severity: normal
>
> The output of the cmp command should be documented. I'm not sure
> there's a bug a not, but it is really strange:
>
> dixsept% printf a > file1
> dixsept% printf ab > file2
> dixsept% cmp file1 file2
> cmp: EOF on file1
> dixsept% cmp file1 file2 > /dev/null
> dixsept% cmp file1 file2 2> /dev/null
> dixsept% cmp=$(cmp file1 file2)
> cmp: EOF on file1
> dixsept% echo $cmp
>
> dixsept% cmp=$(cmp file1 file2 2> /dev/null)
> dixsept% echo $cmp
>
> dixsept% cmp=$(cmp file1 file2 2>&1)
> dixsept% echo $cmp
> cmp: EOF on file1
> dixsept%
>
> I don't think it is POSIX compliant.
>
> http://www.opengroup.org/onlinepubs/009695399/utilities/cmp.html
>
> For instance, with "cmp file1 file2 > /dev/null", there should be
> an output to stderr in the above case.
I think the bug is here in cmp.c:
if (fstat (STDOUT_FILENO, &outstat) == 0
&& stat (NULL_DEVICE, &nullstat) == 0
&& 0 < same_file (&outstat, &nullstat))
comparison_type = type_status;
The test on STDOUT_FILENO isn't sufficient as output is performed
on stderr in this case. Am I right?
--
Vincent Lefèvre <address@hidden> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
- Re: diff: incorrect and undocumented cmp output when stdout is redirected,
Vincent Lefevre <=