Subject: Re: bug#7785: rgrep is broken on woe32

From: Sam Steingold <[email-masked]>
Date: Thu, 6 Jan 2011 10:17:17 -0500

On Thu, Jan 6, 2011 at 5:24 AM, Eli Zaretskii <[email-masked]> wrote:
>> Date: Wed, 5 Jan 2011 18:49:54 -0500
>> From: Sam Steingold <[email-masked]>
>> Cc: [email-masked], [email-masked]
>>
>> so I have to modify process-environment too:
>> after fixing exec-path:
>
> I suggest to fix PATH outside Emacs instead.  I wrote in bug#7793 why.

is it safe to prepend gnuwin path before the system windows paths
globally for all programs?
my toolchain is not limited to the gnu world, I am afraid of breaking,
e.g., ms visual studio...

>> \( -iname \*.el \) -print0 | xargs -0 -e grep -i -nH gnu.org
>> find: paths must precede expression
>> Usage: find [-H] [-L] [-P] [path...] [expression]
>>
>> Grep finished (matches found) at Wed Jan 05 18:44:10
>> ==========================================================
>>
>> the error message is obviously from gnu find, but I don't see what is
>> wrong with the command line.
>
> Which find/xargs/grep are these -- Cygwin's or GnuWin32's?

it should be gnuwin.

> Also, you said just a couple of messages ago, that rgrep did work for
> you in "emacs -q".  So is the only difference between that and this
> whatever you have on your .emacs?  Or am I missing something else?

1. "emacs -Q" started from bash shell:

(getenv "PATH")
"C:\\gnu\\cygwin\\usr\\local\\bin;C:\\gnu\\cygwin\\bin;C:\\gnu\\cygwin\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\gnu\\clisp-2.49;C:\\Program
Files\\TortoiseSVN\\bin;C:\\gnu\\gnuwin32\\bin;C:\\gnu\\cygwin\\bin;D:\\bin;C:\\Program
Files (x86)\\TortoiseHg\\;C:\\Program Files
(x86)\\Bazaar;C:\\gnu\\GnuTLS-2.10.1\\bin"

find . "(" -path "*/SCCS" -o -path "*/RCS" -o -path "*/CVS" -o -path
"*/MCVS" -o -path "*/.svn" -o -path "*/.git" -o -path "*/.hg" .....
-exec grep -i -nH "asdf" {} NUL ";"

grep: NUL: No such file or directory
grep: NUL: No such file or directory
grep: NUL: No such file or directory
grep: NUL: No such file or directory
grep: NUL: No such file or directory

i.e., cygwin tools are used, which sucks because of NULs but at least
things sort of work.

2. emacs started from cygwin bash shell, the only thing in .emacs:
  (let ((gw "c:/gnu/gnuwin32/bin"))
    (setq exec-path (cons gw (delete gw exec-path))))
  (setenv "PATH"
          (mapconcat (lambda (s) (subst-char-in-string ?/ ?\\ s))
                     exec-path ";"))

(getenv "PATH")
"c:\\gnu\\gnuwin32\\bin;c:\\gnu\\cygwin\\usr\\local\\bin;C:\\gnu\\cygwin\\bin;C:\\gnu\\cygwin\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\gnu\\clisp-2.49;C:\\Program
Files\\TortoiseSVN\\bin;C:\\gnu\\gnuwin32\\bin;C:\\gnu\\cygwin\\bin;D:\\bin;C:\\Program
Files (x86)\\TortoiseHg\\;C:\\Program Files
(x86)\\Bazaar;C:\\gnu\\GnuTLS-2.10.1\\bin;c:\\sds\\src\\emacs\\trunk\\bin"

find . "(" -path "*/SCCS" -o -path "*/RCS" -o -path "*/CVS"
-o.....-name "*.kys" -o -name "*.pgs" -o -name "*.tps" -o -name
"*.vrs" -o -name "*.pyc" -o -name "*.pyo" ")" -prune -o  -type f "("
-iname "*" -o -iname ".*" ")" -print0 | xargs -0 -e grep -i -nH "sfdg"
xargs: grep: No such file or directory
grep: ./src/clisp/current/src/config: No such file or directory
find: write error: Invalid argument

i.e., apparently, gnuwin tools are used, but nothing works.

3. emacs started with the above .emacs from the desktop shortcut

(getenv "PATH")
"c:\\gnu\\gnuwin32\\bin;c:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\gnu\\clisp-2.49;C:\\Program
Files\\TortoiseSVN\\bin;c:\\gnu\\cygwin\\bin;d:\\bin;C:\\Program Files
(x86)\\TortoiseHg\\;C:\\Program Files
(x86)\\Bazaar;C:\\gnu\\GnuTLS-2.10.1\\bin;c:\\sds\\src\\emacs\\trunk\\bin"

find . "(" -path "*/SCCS" -o -path "*/RCS" -o -path "*/CVS" ..... -o
-name "*.pyo" ")" -prune -o  -type f "(" -iname "*" -o -iname ".*" ")"
-print0 | xargs -0 -e grep -i -nH "adsf"
xargs: grep: No such file or directory
grep: ./src/clisp/curr: No such file or directory
find: write error: Invalid argument

i.e., same problems as before.

4. emacs started from desktop with my full huge .emacs but without PATH tweaking

(getenv "PATH")
"C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\gnu\\clisp-2.49;C:\\Program
Files\\TortoiseSVN\\bin;c:\\gnu\\gnuwin32\\bin;c:\\gnu\\cygwin\\bin;d:\\bin;C:\\Program
Files (x86)\\TortoiseHg\\;C:\\Program Files
(x86)\\Bazaar;C:\\gnu\\GnuTLS-2.10.1\\bin"

c:/gnu/gnuwin32/bin/find . \( -path  -o -path \*/attic ..... -o -iname
Makefile\* -o -iname \*.xml \) -print0 | c:/gnu/gnuwin32/bin/xargs -0
-e c:/gnu/gnuwin32/bin/grep -i -nH sadf
'c:' is not recognized as an internal or external command,
operable program or batch file.

5. same as 4 but without setting find-program et al
FIND: Parameter format not correct

6. emacs started from desktop with my full huge .emacs with PATH
tweaking without setting find-program et al:

(getenv "PATH")
"c:\\gnu\\gnuwin32\\bin;c:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\gnu\\clisp-2.49;C:\\Program
Files\\TortoiseSVN\\bin;c:\\gnu\\cygwin\\bin;d:\\bin;C:\\Program Files
(x86)\\TortoiseHg\\;C:\\Program Files
(x86)\\Bazaar;C:\\gnu\\GnuTLS-2.10.1\\bin;c:\\sds\\src\\emacs\\trunk\\bin"

find . \( -path  -o -path \*/attic -o -path .....-iname \*.in -o
-iname Makefile\* -o -iname \*.xml \) -print0 | xargs -0 -e grep -i
-nH asdf
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]

7. emacs -Q started from desktop:

(getenv "PATH")
"C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\gnu\\clisp-2.49;C:\\Program
Files\\TortoiseSVN\\bin;c:\\gnu\\gnuwin32\\bin;c:\\gnu\\cygwin\\bin;d:\\bin;C:\\Program
Files (x86)\\TortoiseHg\\;C:\\Program Files
(x86)\\Bazaar;C:\\gnu\\GnuTLS-2.10.1\\bin"

find . "(" -path "*/SCCS" ... -name "*.pyc" -o -name "*.pyo" ")"
-prune -o  -type f "(" -iname "*" -o -iname ".*" ")" -exec grep -i -nH
"rg	" {} NUL ";"
FIND: Parameter format not correct

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