GNU bug report logs - #23453
25.0.93; dired-do-find-regexp does not work on Windows even after installing GNU find and grep

Previous Next

Package: emacs;

Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>

Date: Wed, 4 May 2016 19:42:02 UTC

Severity: normal

Found in version 25.0.93

Done: Kaushal Modi <kaushal.modi <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 23453 <at> debbugs.gnu.org
Subject: bug#23453: 25.0.93; dired-do-find-regexp does not work on Windows even after installing GNU find and grep
Date: Wed, 04 May 2016 22:30:11 +0000
[Message part 1 (text/plain, inline)]
>
> > +   (shell-quote-argument dir)
>
> This looks good.
>

Thanks.


> > +   (xref--find-ignores-arguments ignores (shell-quote-argument dir))))
>
> I'm not sure about this line, on the other hand. Is it actually
> required?


My guess would be yes based on just C-h f xref--find-ignores-arguments.

Convert IGNORES and DIR to a list of arguments for ’find’.
IGNORES is a list of glob patterns.  DIR is an absolute
directory, used as the root of the ignore globs.

If DIR is going to be an argument to `find', it should be shell quoted too,
right? For the example in this bug report though, it does not matter with
or without shell quoting dir there (in arg to
xref--find-ignores-arguments). The second version of patch simply has the
shell-quote-argument propagated into the xref--rgrep-command.


> If yes, this quoting should be performed inside
> xref--find-ignores-arguments, I think.


Or how about this 3rd version of the patch:

From 1f114a74de1d28e06edd9c074774a087c1d19bd5 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi <at> gmail.com>
Date: Wed, 4 May 2016 18:25:50 -0400
Subject: [PATCH] Shell escape arguments for find/grep used by xref

* lisp/progmodes/xref.el (xref--rgrep-command): When the dir has
  characters like spaces (e.g. /tmp/some dir/), those need to be escaped
  before passing it as an argument to the shell command like `find'.
  The escaping is done using `shell-quote-argument' (bug#23453).
---
 lisp/progmodes/xref.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 62cef23..ccf20c1 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -910,6 +910,7 @@ xref--rgrep-command
   (require 'find-dired)      ; for `find-name-arg'
   (defvar grep-find-template)
   (defvar find-name-arg)
+  (setq dir (shell-quote-argument dir)) ; /some dir/ → /some\ dir/
   (grep-expand-template
    grep-find-template
    regexp
-- 
2.6.0.rc0.24.gec371ff

It feels untidy to shell-quote dir separately; once in the
grep-expand-template form and second time inside
xref--find-ignores-arguments. Also it could get confusing keeping track of
if dir was already shell-quoted by the time it entered
xref--find-ignores-arguments or not.

A comment in that last function also says:

    ;; `shell-quote-argument' quotes the tilde as well.
    (cl-assert (not (string-match-p "\\`~" dir)))

So looks like dir is expected to be shell-quoted before it entered that
function.


-- 

-- 
Kaushal Modi
[Message part 2 (text/html, inline)]

This bug report was last modified 9 years and 17 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.