Subject: bug#7785: rgrep is broken on woe32

From: Sam Steingold <[email-masked]>
Date: Thu, 6 Jan 2011 11:04:38 -0500

On Thu, Jan 6, 2011 at 5:24 AM, Eli Zaretskii <[email-masked]> wrote:
>
> There's something else I don't understand.  The style of shell quoting
> you show, viz.
>
>  find . \( -path  -o -path \*/attic -o -path \*/junk -o -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
>
> is different from what I see on my Windows box:
>
>  find . "(" -path  -o -path "*/attic" -o -path "*/junk" -o -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
>
> That is, Emacs is supposed to use double quotes on Windows, because
> Windows programs (except Cygwin) don't understand quoting with a
> backslash.  Do you see the former style of quoting in "emacs -Q" as
> well?

the problem is with w32-fns.el.
I set explicit-shell-file-name to "bash" because whenever I start an
explicit interactive shell,
I want it to be bash and not the windows crap.
however, this has nothing to do with the shell used to interpret
individual commands
like M-! and M-x rgrep.
specifically, since explicit-shell-file-name is "bash", w32-shell-name
returns "bash"
and thus w32-shell-dos-semantics returns nil and shell-quote-argument
thus uses backslashes.
I think this is wrong.
I propose this patch:

=== modified file 'lisp/w32-fns.el'
--- lisp/w32-fns.el	2010-10-24 22:04:45 +0000
+++ lisp/w32-fns.el	2011-01-06 15:58:02 +0000
@@ -57,7 +57,7 @@ That includes all Windows systems except

 (defun w32-shell-name ()
   "Return the name of the shell being used."
-  (or (bound-and-true-p explicit-shell-file-name)
+  (or (bound-and-true-p shell-file-name)
       (getenv "ESHELL")
       (getenv "SHELL")
       (and (w32-using-nt) "cmd.exe")

is it OK to commit?

with this patch and my full .emacs with PATH tweaking and without
find-program setting:

find . "(" -path  -o ...  -type f "(" -iname "*.[cdfh]" -o -iname
"*.lisp" -o -iname "*.tst" -o -iname "*.m4" -o -iname "*.in" -o -iname
"Makefile*" -o -iname "*.xml" ")" -print0 | xargs -0 -e grep -i -nH
"asdf"
xargs: grep: No such file or directory

i.e., it still does not work, despite:

(getenv "PATH")
"c:\\gnu\\gnuwin32\\bin;c:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;c:\\gnu\\cygwin\\bin;d:\\bin;C:\\gnu\\clisp-2.49;C:\\Program
Files\\TortoiseSVN\\bin;C:\\Program Files
(x86)\\TortoiseHg\\;C:\\Program Files
(x86)\\Bazaar;C:\\gnu\\GnuTLS-2.10.1\\bin;c:\\sds\\src\\emacs\\trunk\\bin"
(executable-find "grep")
"c:/gnu/gnuwin32/bin/grep.exe"
and M-! grep RET working.

-- 
Sam Steingold <http://sds.podval.org>