Subject: RE: bug#2397: 23.0.90; grep no longer highlights the match

From: "Drew Adams" <[email-masked]>
Date: Sat, 28 Feb 2009 10:02:04 -0800

> > > >> Could you also try running grep from Bash (not from Emacs)
> > > >> with options "--color=always" and "--color=auto" and 
> > > >> see whether it outputs highlighting sequences for both
> > > >> cases in a standalone shell?
> > > >
> > > > Yes, both produce the highlighting.
> > > > It is apparently only in Emacs that --color=auto does not work.
> > > 
> > > Weird.  Maybe a Windows guru could explain the difference.
> > 
> > I think it's an Emacs guru that's needed (perhaps with some 
> > Windows, Cygwin, or GNU bash knowledge).
> 
> I think this has nothing to do with either Cygwin or Bash.  Drew,
> could you please verify that the same problem happens for you in
> "emacs -Q" without loading cygwin-mount.el and setup-cygwin.el?

No, sorry, that won't help. With only `emacs -Q' I get this error whenever I try
`M-x grep': "apply: Spawning child process: invalid argument".

Always have, on Windows. Makes sense, no? (Or at least some error makes sense.)
Vanilla Windows has no `grep' program.

> AFAICT, this problem happens because Emacs on Windows invokes
> subsidiary programs through a pipe, and that pipe fails the `isatty'
> test in Grep.  So "--color=auto" can never work on MS-Windows when
> Grep is invoked by Emacs.
> 
> I ``fixed'' this by going back, on DOS/Windows only, to the
> "--color=always" way we used before Juri installed his 2007-11-23
> changes.  It's true that this will reinstate the original problem with
> multiple grep invocations in a pipe (on Windows and DOS only), but I
> don't see how can that use-case be solved, and having a single
> instance of grep in the command is by far more frequent usage.
> 
> Here's the change I installed.  Drew, could you please see if it works
> for you as well?

Yes, it works fine for me. Thanks.