From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.bugs 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-ID: References: <834madioy0.fsf@gnu.org> <48af9fd9-2b0a-7c67-9141-c2236c62e318@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e013d08f0605fb605320bc5c4 X-Trace: ger.gmane.org 1462401103 26520 80.91.229.3 (4 May 2016 22:31:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 May 2016 22:31:43 +0000 (UTC) Cc: 23453@debbugs.gnu.org To: Dmitry Gutov , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu May 05 00:31:33 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ay5KP-0005jK-L3 for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 May 2016 00:31:33 +0200 Original-Received: from localhost ([::1]:50600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay5KL-0007XM-DV for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 May 2016 18:31:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay5KB-0007Iy-6k for bug-gnu-emacs@gnu.org; Wed, 04 May 2016 18:31:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ay5Jy-0002IZ-SZ for bug-gnu-emacs@gnu.org; Wed, 04 May 2016 18:31:13 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay5Jx-0002HC-Lh for bug-gnu-emacs@gnu.org; Wed, 04 May 2016 18:31:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ay5Ju-0001Y5-7C for bug-gnu-emacs@gnu.org; Wed, 04 May 2016 18:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 May 2016 22:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23453 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23453-submit@debbugs.gnu.org id=B23453.14624010285910 (code B ref 23453); Wed, 04 May 2016 22:31:02 +0000 Original-Received: (at 23453) by debbugs.gnu.org; 4 May 2016 22:30:28 +0000 Original-Received: from localhost ([127.0.0.1]:38453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ay5JM-0001XF-2o for submit@debbugs.gnu.org; Wed, 04 May 2016 18:30:28 -0400 Original-Received: from mail-ob0-f173.google.com ([209.85.214.173]:33178) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ay5JK-0001X0-SK for 23453@debbugs.gnu.org; Wed, 04 May 2016 18:30:27 -0400 Original-Received: by mail-ob0-f173.google.com with SMTP id x1so28197698obt.0 for <23453@debbugs.gnu.org>; Wed, 04 May 2016 15:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rVEVH2sQpxaGujrtYrPRGT+nTYE20GHsjAKaiz0odMU=; b=cqdK7Lc0KvXoiGS0UccbHY5cf4m8O5sifGHkm0TrnEbAMY4Oo0fxPYMtcrAeZHJWvK UIe9RUoNilISslHqGbWSkYYKGO06ul0nztxGxvAcg2MLhCyc2J3nRwGFiWHLUbjhBXTk T/2auM7bA12Jb538Q3Odc9YTxAjYBVzeDezd7niJ93TmBUE46u1VTQKFhhQ2ZD51QE7g Qw3+q5tmUO8eMgKwYdDFv1msPkVPeC99tN9+Pti2hKlZgz6owEGXflvtqMFAGQgJoS8u p/poa2SPJ9o9AmyrN3XU55OuPMaRh1l7cLj150DEBYYZcb7vMWy/TKYDqFEJK/qYNNuG sHJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rVEVH2sQpxaGujrtYrPRGT+nTYE20GHsjAKaiz0odMU=; b=HqaBnVAUNtlR8JzGIbKdgKQLgCqhetMMEZqkTYvPNTem7MJR/g0FUviP3d3oETt9IP 9vOeO47sbUNlp2DOBcTJeUW/P1wgnwnPVxI9fgH6P6WwxmIgRmVYtO1eb4m/LRr4wJmt Lln3eMbE16wKxiCfSoR1khEgTkJHAgNuzGjAc4qkc3IXlgxY8wj9jWAW5X+Uxf6Z+89f 7cw0zAzCIhpfUdSnWOF/7Odack+dcsplnccgyKDPv0YckFg9hfMAf96DI20ayVc3T9t2 G/UPiw6yxanC7PqeXHuNEtKzxJs8HlnPnGJc603ZMhA7wCK+mTJFxs3MgsUbPtqY+TS/ 4BqQ== X-Gm-Message-State: AOPr4FXiaroZcjKfgsi86NoZ9FujXhusYNbtAnR4345F6pi4wIaxGRU/NZ+zYELZye5710yeeRDkaNXrtZORzQ== X-Received: by 10.60.38.225 with SMTP id j1mr3400964oek.24.1462401021007; Wed, 04 May 2016 15:30:21 -0700 (PDT) In-Reply-To: <48af9fd9-2b0a-7c67-9141-c2236c62e318@yandex.ru> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:117819 Archived-At: --089e013d08f0605fb605320bc5c4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > > > + (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 =E2=80=99find=E2=80=99. 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 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/ =E2=86=92 /some\ dir/ (grep-expand-template grep-find-template regexp --=20 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. --=20 --=20 Kaushal Modi --089e013d08f0605fb605320bc5c4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
= > +=C2=A0 =C2=A0(shell-quote-argument dir)

This looks good.

Thanks.
=C2= =A0
> +=C2=A0 =C2=A0(xref--find-ignores-arguments ignores (shell-quote-argum= ent dir))))

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

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

Convert IG= NORES and DIR to a list of arguments for =E2=80=99find=E2=80=99.
= IGNORES is a list of glob patterns.=C2=A0 DIR is an absolute
dire= ctory, used as the root of the ignore globs.

If DI= R 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 o= r 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.
=C2=A0
If yes, this quoting should be performed inside
xref--find-ignores-arguments, I think.

Or h= ow about this 3rd version of the patch:

From 1f114= a74de1d28e06edd9c074774a087c1d19bd5 Mon Sep 17 00:00:00 2001
From= : Kaushal Modi <kaushal.modi@g= mail.com>
Date: Wed, 4 May 2016 18:25:50 -0400
S= ubject: [PATCH] Shell escape arguments for find/grep used by xref

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

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/= xref.el
index 62cef23..ccf20c1 100644
--- a/lisp/progmo= des/xref.el
+++ b/lisp/progmodes/xref.el
@@ -910,6 +910= ,7 @@ xref--rgrep-command
=C2=A0 =C2=A0(require 'find-dired) = =C2=A0 =C2=A0 =C2=A0; for `find-name-arg'
=C2=A0 =C2=A0(defva= r grep-find-template)
=C2=A0 =C2=A0(defvar find-name-arg)
+ =C2=A0(setq dir (shell-quote-argument dir)) ; /some dir/ =E2=86=92 /so= me\ dir/
=C2=A0 =C2=A0(grep-expand-template
=C2=A0 =C2= =A0 grep-find-template
=C2=A0 =C2=A0 regexp
--=C2=A0
2.6.0.rc0.24.gec371ff

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

A comment in that la= st function also says:

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

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

--
Kaushal Modi

--089e013d08f0605fb605320bc5c4--