Subject: bug#48302: [PATCH] Abbreviate `find' properties in M-x rgrep on MS Windows

From: Jim Porter <[email-masked]>
Date: Sat, 8 May 2021 15:17:14 -0700

MS Windows has different shell-quoting logic from POSIX shells, so the
regexp to abbreviate the `find' command's properties in rgrep fails to
match on MS Windows. The attached patch fixes this by looking for
either `\)' (POSIX) or `")"' (MS Windows) as the end of the properties
list.

Steps to reproduce:

  ;; Ensure GNU find and grep are in your path
  emacs -Q
  M-x rgrep RET foo RET RET RET
  ;; See the full, unabbreviated command instead of `find [...] -exec grep'...

To make things easier to review for people without access to MS
Windows, this is the full invocation for rgrep:

---------- Begin Block ----------

find . -type d "(" -path "*/SCCS" -o -path "*/RCS" -o -path "*/CVS" -o
-path "*/MCVS" -o -path "*/.src" -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" -o -name
"*.fasl" -o -name "*.ufsl" -o -name "*.fsl" -o -name "*.dxl" -o -name
"*.lo" -o -name "*.la" -o -name "*.gmo" -o -name "*.mo" -o -name
"*.toc" -o -name "*.aux" -o -name "*.cp" -o -name "*.fn" -o -name
"*.ky" -o -name "*.pg" -o -name "*.tp" -o -name "*.vr" -o -name
"*.cps" -o -name "*.fns" -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 ^".[^!.]*^" -o -iname "..?*" ")"
-exec grep --color=always -i -nH --null "foo" "{}" ";"

---------- End Block ----------