public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Michael Enright <mike@kmcardiff.com>
To: cygwin@cygwin.com
Subject: Re: cmp (or echo) bug?
Date: Mon, 28 Dec 2015 18:20:00 -0000	[thread overview]
Message-ID: <CAOC2fq_mZtrX-EyT6QkzoSfXgqQW8OHsiPmoeBktosfE1cx2xQ@mail.gmail.com> (raw)
In-Reply-To: <CAPJ9Yc9zSpvPLE3kDvFGoS9w9Btuazw2CVOTHZoDDtuoO8UG6w@mail.gmail.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

  reply	other threads:[~2015-12-28 18:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-25 21:32 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOC2fq_mZtrX-EyT6QkzoSfXgqQW8OHsiPmoeBktosfE1cx2xQ@mail.gmail.com \
    --to=mike@kmcardiff.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).