cmp (or echo) bug?
David Balažic
xerces9@gmail.com
Sun Jan 3 17:21:00 GMT 2016
cat and diff work as expected:
$ cat <(echo echo1) <(echo echo2)
echo1
echo2
$ diff <(echo echo1) <(echo echo2)
1c1
< echo1
---
> echo2
So maybe the bug is really in cmp.
Regards,
David
On 29 December 2015 at 17:43, Houder <houder@xs4all.nl> wrote:
> On 2015-12-25 22:32, David Balažic wrote:
>>
>> Hi!
>>
>> In Cygwin terminal (bash) I typed:
>>
>> cmp <(echo echo1) <(echo echo2)
>>
>> This does not print anything.
>> Not even with -b.
>>
>> On Linux (Ubuntu 12.04 in VMWare) it reports that the inputs are
>> different.
>>
>> Bug?
>> Or am I missing something?
>
>
> @@ uname -a
> CYGWIN_NT-6.1-WOW Seven 2.3.1(0.291/5/3) 2015-11-14 12:42 i686 Cygwin
> @@ ./cmp <(echo echo1) <(echo echo2)
> /dev/fd/63 /dev/fd/62 differ: byte 5, line 1
> @@ ./cmp <(echo echo1) <(echo echo2)
> /dev/fd/63 /dev/fd/62 differ: byte 5, line 1
> @@ ./cmp <(echo echo1) <(echo echo2)
> /dev/fd/63 /dev/fd/62 differ: byte 5, line 1
> @@ ./cmp <(echo echo1) <(echo echo2)
> /dev/fd/63 /dev/fd/62 differ: byte 5, line 1
> @@ ./cmp <(echo echo1) <(echo echo2)
> /dev/fd/63 /dev/fd/62 differ: byte 5, line 1
> @@ ./cmp <(echo echo1) <(echo echo2)
> /dev/fd/63 /dev/fd/62 differ: byte 5, line 1
>
> etc.
>
> But only after I had modified cmp.c (diffutils) as follows:
>
> int
> main (int argc, char **argv)
> {
> ...
>
> #if 0
> if (file_desc[f1] < 0 || fstat (file_desc[f1], stat_buf + f1) != 0)
> #else
> if (file_desc[f1] < 0 || f1 ? ( stat (file[1], stat_buf + f1) != 0 )
> : ( stat (file[0], stat_buf + f1) != 0 ) )
> // Henri: suspect fstat
> #endif
> {
> if (file_desc[f1] < 0 && comparison_type == type_status)
> exit (EXIT_TROUBLE);
> else
> error (EXIT_TROUBLE, errno, "%s", file[f1]);
> }
> }
>
> /* If the files are links to the same inode and have the same file
> position,
> they are identical. */
>
> if (0 < same_file (&stat_buf[0], &stat_buf[1])
> && same_file_attributes (&stat_buf[0], &stat_buf[1])
> && file_position (0) == file_position (1))
> { // Henri: diagnostics
> #if 0
> printf("same_file = %d\n", same_file (&stat_buf[0], &stat_buf[1]) );
> printf("same_file_attributes = %d\n", same_file_attributes
> (&stat_buf[0], &stat_buf[1]) );
> printf("same file pos = %d\n", file_position (0) == file_position (1) );
> #endif
> printf("file[0] = %s, file[1] = %s\n", file[0], file[1]);
> printf("file_desc[0] = %d, file_desc[1] = %d\n", file_desc[0],
> file_desc[1]);
> printf("bailing out: same file.\n");
> return EXIT_SUCCESS;
> }
>
> Regards,
> Henri
>
>
>
> --
> Problem reports: http://cygwin.com/problems.html
> FAQ: http://cygwin.com/faq/
> Documentation: http://cygwin.com/docs.html
> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
>
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list