Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.