This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cmp (or echo) bug?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]