Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Preparing a new machine for development, I upgraded Cygwin and the CVS client as described in the subject line: from (Cygwin 1.5.5-1 + CVS 1.11.21) to (cygwin-1.7.5 + CVS 1.11.22)

All went well, but a 1-line convenience bash script I have been carrying around for years stopped working. It used to filter out all uninteresting lines from 'cvs status':

cvs status | grep -F File | grep -v Up-to-date

In the new version, it seemed as if "grep -v" simply stopped working (i.e. wasn't filtering OUT anything). So I tried:

cvs status 2>&1 | grep -F File | grep -v Up-to-date

But that didn't change the behavior. The output was still as if "grep -v" were never called. So, I tried:

cvs status 2>&1 | grep -F File 2>&1 | grep -v Up-to-date

And that solved the problem! The script now behaves identically in (Cygwin 1.5.5-1 + CVS 1.11.21) and (cygwin-1.7.5 + CVS 1.11.22).

My question now is why?

What happened to Cygwin's grep that it now requires redirection from stderr to stdout?

Please note that I intentionally emphasized the word script, because the original command (the first one quoted above) still works identically in both old and new environments, if typed from the command line (i.e. not inside a #!/bin/bash script).

Any idea why this is?

share|improve this question
Not helpful enough to be an answer, but I've always found to be much more user-friendly than Cygwin. – user31752 Sep 2 '10 at 3:32
Interesting. Never heard of andlinux before. Thanks for introducing to me. +1 for that. – Android Eve Sep 2 '10 at 5:00

I don't know for sure in this case, but a common cause of scripts failing to work with newer versions of Cygwin's bash is DOS (CR-LF) line endings. Perhaps your last change to that script also changed the line ending. Make sure your scripts use only Unix (LF) line endings. Otherwise, grep will see its pattern argument as "Up-to-date^M".

share|improve this answer
+1 for attempting to decipher this mystery. No, the problem doesn't lie in the CRLF vs. LF ending. As I have both versions of the script with the same exact line ending (I use Emacs in hexl-mode to see exactly what's in it). I suspect the problem has to do with forking and/or inheriting the environment. Something has changed and I suspect it's in Cygwin, not in CVS. – Android Eve Sep 2 '10 at 2:08
up vote 0 down vote accepted

It's time to accept an answer. The only reasonable explanation so far is that something has changed in they way Cygwin's grep splits output to stderr and stdout. If a better or more authoritative answer comes along, I will consider accepting it.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .