[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23453: 25.0.93; dired-do-find-regexp does not work on Windows even a

From: Kaushal Modi
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

> +   (shell-quote-argument dir)

This looks good.

> +   (xref--find-ignores-arguments ignores (shell-quote-argument dir))))

I'm not sure about this line, on the other hand. Is it actually

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 <address@hidden>
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/

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]