* cmp (or echo) bug? @ 2015-12-25 21:32 David Balažic 2015-12-26 6:42 ` Marco Atzeri ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: David Balažic @ 2015-12-25 21:32 UTC (permalink / raw) To: cygwin 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? I just updated to latest version of cygwin, to be sure. 32 bit version. On Windows 8.1 Pro x64 (all updates) Regards, David -- 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-25 21:32 cmp (or echo) bug? David Balažic @ 2015-12-26 6:42 ` Marco Atzeri 2015-12-26 12:49 ` Ismail Donmez 2015-12-29 16:43 ` Houder 2 siblings, 0 replies; 10+ messages in thread From: Marco Atzeri @ 2015-12-26 6:42 UTC (permalink / raw) To: cygwin On 25/12/2015 22:32, David Balažic wrote: > Hi! > > In Cygwin terminal (bash) I typed: > > cmp <(echo echo1) <(echo echo2) only on 32bit, on 64 I see $ cmp <(echo echo1) <(echo echo2) /dev/fd/63 /dev/fd/62 differ: byte 5, line 1 I suspect a timing issue, and the result is not well defined > 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? > > I just updated to latest version of cygwin, to be sure. > 32 bit version. > On Windows 8.1 Pro x64 (all updates) > > Regards, > David > -- 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-25 21:32 cmp (or echo) bug? David Balažic 2015-12-26 6:42 ` Marco Atzeri @ 2015-12-26 12:49 ` Ismail Donmez 2015-12-27 17:23 ` Helmut Karlowski 2015-12-28 17:08 ` David Balažic 2015-12-29 16:43 ` Houder 2 siblings, 2 replies; 10+ messages in thread From: Ismail Donmez @ 2015-12-26 12:49 UTC (permalink / raw) To: cygwin Hi, David Balažic <xerces9 <at> gmail.com> writes: > In Cygwin terminal (bash) I typed: > > cmp <(echo echo1) <(echo echo2) I suspect its a bash bug since it works fine with zsh (tested 64bit only). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-26 12:49 ` Ismail Donmez @ 2015-12-27 17:23 ` Helmut Karlowski 2015-12-28 17:08 ` David Balažic 1 sibling, 0 replies; 10+ messages in thread From: Helmut Karlowski @ 2015-12-27 17:23 UTC (permalink / raw) To: cygwin; +Cc: cygwin --------------------------------------------------- > Hi, > > David Balaic <xerces9 <at> gmail.com> writes: > > > In Cygwin terminal (bash) I typed: > > > > cmp <(echo echo1) <(echo echo2) > > I suspect its a bash bug since it works fine with zsh (tested 64bit only). zsh uses temp-files for process-substitution, while bash seems to use pipes which are not very good seekable. That might cause the difference. It only works in zsh and no other shell because of that. Diff instead of cmp works also in bash btw. -Helmut -- 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-26 12:49 ` Ismail Donmez 2015-12-27 17:23 ` Helmut Karlowski @ 2015-12-28 17:08 ` David Balažic 2015-12-28 18:20 ` Michael Enright 1 sibling, 1 reply; 10+ messages in thread From: David Balažic @ 2015-12-28 17:08 UTC (permalink / raw) To: cygwin I tried it in zsh (32 bit cygwin) and there it works correctly: $ cmp <(echo echo1) <(echo echo2) /tmp/zshirbIJ1 /tmp/zshDsdZep differ: byte 5, line 1 So it seems the bug is in bash. Regards, David On 26 December 2015 at 13:49, Ismail Donmez <ismail@i10z.com> wrote: > Hi, > > David Balažic <xerces9 <at> gmail.com> writes: > >> In Cygwin terminal (bash) I typed: >> >> cmp <(echo echo1) <(echo echo2) > > I suspect its a bash bug since it works fine with zsh (tested 64bit only). -- 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-28 17:08 ` David Balažic @ 2015-12-28 18:20 ` Michael Enright 2015-12-28 20:58 ` David Balažic 0 siblings, 1 reply; 10+ messages in thread From: Michael Enright @ 2015-12-28 18:20 UTC (permalink / raw) To: cygwin On Mon, Dec 28, 2015 at 9:08 AM, David Balažic wrote: > I tried it in zsh (32 bit cygwin) and there it works correctly: > > $ cmp <(echo echo1) <(echo echo2) > /tmp/zshirbIJ1 /tmp/zshDsdZep differ: byte 5, line 1 > > So it seems the bug is in bash. > A different conclusion is also supportable: That the two pipe mechanisms have different edge-case behavior, resulting in different outcomes for the command depending on which pipe type is used.. I tried this on 32-bit cygwin, Windows 7/64: $ cmp <(for i in 1 2 3 4 5; do echo echo$i; done) <(for i in 1 2 3 4 6; do echo echo$i; done) /dev/fd/63 /dev/fd/62 differ: byte 29, line 5 Your output from zsh shows named pipes are in use. "man zshexpn" says that zsh can use anonymous pipes, yet it chose not to in your case. In my case bash chose to use anonymous pipes, even though "man bash" says it may use named pipes. The man pages for these shells describe essentially the same syntax and mechanisms for this process substitution mechanism. What is not defined: 1) How do commands such as my for loop command or your simple echo command provide output properly so that EOF isn't detected spuriously 2) How do programs such as cmp or diff read from their input in such a way that they are not fooled by a file status that might appear to be EOF but isn't. 3) Crystalline clarity as to when the shell prefers one pipe type to another, at least not to this reader, and not that it matters. -- 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-28 18:20 ` Michael Enright @ 2015-12-28 20:58 ` David Balažic 2015-12-29 4:50 ` Andrey Repin 0 siblings, 1 reply; 10+ messages in thread From: David Balažic @ 2015-12-28 20:58 UTC (permalink / raw) To: cygwin It is irrelevant how it is implemented. The command means "compare the output of those two commands" and the only correct result is "they differ on byte 5". It is clearly a bug. -- 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-28 20:58 ` David Balažic @ 2015-12-29 4:50 ` Andrey Repin 0 siblings, 0 replies; 10+ messages in thread From: Andrey Repin @ 2015-12-29 4:50 UTC (permalink / raw) To: David Balažic, cygwin Greetings, David Balažic! > It is irrelevant how it is implemented. The command means "compare the > output of those two commands" and the only correct result is "they > differ on byte 5". > It is clearly a bug. I wouldn't be so hastily jumping to conclusions, if I were you. -- With best regards, Andrey Repin Tuesday, December 29, 2015 07:39:06 Sorry for my terrible english... ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-25 21:32 cmp (or echo) bug? David Balažic 2015-12-26 6:42 ` Marco Atzeri 2015-12-26 12:49 ` Ismail Donmez @ 2015-12-29 16:43 ` Houder 2016-01-03 17:21 ` David Balažic 2 siblings, 1 reply; 10+ messages in thread From: Houder @ 2015-12-29 16:43 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: cmp (or echo) bug? 2015-12-29 16:43 ` Houder @ 2016-01-03 17:21 ` David Balažic 0 siblings, 0 replies; 10+ messages in thread From: David Balažic @ 2016-01-03 17:21 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-01-03 17:21 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-12-25 21:32 cmp (or echo) bug? David Balažic 2015-12-26 6:42 ` Marco Atzeri 2015-12-26 12:49 ` Ismail Donmez 2015-12-27 17:23 ` Helmut Karlowski 2015-12-28 17:08 ` David Balažic 2015-12-28 18:20 ` Michael Enright 2015-12-28 20:58 ` David Balažic 2015-12-29 4:50 ` Andrey Repin 2015-12-29 16:43 ` Houder 2016-01-03 17:21 ` David Balažic
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).