This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: cmp (or echo) bug?
- From: Michael Enright <mike at kmcardiff dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 28 Dec 2015 10:20:31 -0800
- Subject: Re: cmp (or echo) bug?
- Authentication-results: sourceware.org; auth=none
- References: <CAPJ9Yc9uFnFSFPkYxJj2A87EzZVNrWx2mN5Pq6SxCwpf_78QVQ at mail dot gmail dot com> <loom dot 20151226T134911-504 at post dot gmane dot org> <CAPJ9Yc9zSpvPLE3kDvFGoS9w9Btuazw2CVOTHZoDDtuoO8UG6w at mail dot gmail dot com>
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