Subject: bug#14985: 24.3; rgrep and accents

From: Eli Zaretskii <[email-masked]>
Date: Tue, 30 Jul 2013 19:10:35 +0300

> From: "Sebastien Vauban" <[email-masked]>
> Date: Tue, 30 Jul 2013 16:47:49 +0200
> 
> If I call the command `rgrep' for recursively searching for the string
> `Contrat signé' in some directory, I get "no matches found".
> 
> --8<---------------cut here---------------start------------->8---
> -*- mode: grep; default-directory: "~/some/dir/" -*-
> Grep started at Tue Jul 30 16:40:06
> 
> find . -type d \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path \*/MCVS -o -path \*/.svn -o -path \*/.git -o -path \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) -prune -o \! -type d \( -name .\#\* -o -name \*.o -o -name \*\~ -o -name \*.bin -o -name \*.bak -o -name \*.obj -o -name \*.map -o -name \*.ico -o -name \*.pif -o -name \*.lnk -o -name \*.a -o -name \*.ln -o -name \*.blg -o -name \*.bbl -o -name \*.dll -o -name \*.drv -o -name \*.vxd -o -name \*.386 -o -name \*.elc -o -name \*.lof -o -name \*.glo -o -name \*.idx -o -name \*.lot -o -name \*.fmt -o -name \*.tfm -o -name \*.class -o -name \*.fas -o -name \*.lib -o -name \*.mem -o -name \*.x86f -o -name \*.sparcf -o -name \*.dfsl -o -name \*.pfsl -o -name \*.d64fsl -o -name \*.p64fsl -o -name \*.lx64fsl -o -name \*.lx32fsl -o -name \*.dx64fsl -o -name \*.dx32fsl -o -name \*.fx64fsl -o -name \*.fx32fsl -o -name \*.sx64fsl -o -name \*.sx32fsl -o -name \*.wx64fsl -o -name \*.wx32fsl -
> 
> Grep finished with no matches found at Tue Jul 30 16:40:06
> --8<---------------cut here---------------end--------------->8---
> 
> If I copy/paste the above (huge) `grep-find' command into a Cygwin (Zsh)
> shell, there it works...
> 
> Without accents in the search expression, it works perfectly from Emacs,
> needless to say.

There are too many unknowns here.

You are mixing Cygwin tools with a native Windows Emacs, which is a
problem.  AFAIK, Cygwin (at least its latest versions) uses UTF-8 to
encode non-ASCII characters, like many Posix platforms do, but
MinGW-compiled Emacs uses the system codepage to do that.

In addition, Emacs does some non-trivial stuff when it invokes Cygwin
programs, and I think this misfires when non-ASCII characters are
involved.  It's possible that you have rediscovered bug #6705, which
see.

To unlock the mystery, I would suggest to find out what does Cygwin
Grep see in its argv[] array in your use case.  One way to find that
out is to compile a simple Cygwin program that just dumps its argv[]
in some ASCII-safe encoding, and invoke it instead of Grep (or rename
it grep.exe for a moment).