GNU bug report logs -
#29303
25.2; vc-git-grep should shell-escape FILES
Previous Next
Reported by: Angus Lees <gus <at> inodes.org>
Date: Wed, 15 Nov 2017 06:51:02 UTC
Severity: normal
Found in version 25.2
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Angus Lees <gus <at> inodes.org> writes:
> "git grep" is recursive. Consequently, the globbing for FILES arg needs
> to be done *inside* git, and not by the shell invoking git.
>
> Specifically: `vc-git-grep` needs to shell-escape the FILES value after
> `grep-read-files` (so `grep-files-aliases` continues to work) and before
> calling `grep-expand-template` (which does no escaping itself).
>
You mean something like the patch below? I considered splitting on
spaces and doing shell-quote-argument, but that seems like overkill.
(this is where someone points me at a function somewhere in emacs that
does exactly this operation already)
[0001-Quote-filenames-to-inhibit-expansion-by-the-shell.patch (text/x-diff, inline)]
From 788126ca723ba2e37553eaf5f17141be3544a5cb Mon Sep 17 00:00:00 2001
From: Robert Pluim <rpluim <at> gmail.com>
Date: Wed, 15 Nov 2017 10:51:37 +0100
Subject: [PATCH] Quote filenames to inhibit expansion by the shell
* lisp/vc/vc-git.el (vc-git-grep): Add quotes around filename patterns
to ensure globbing is done by git rather than the shell. (Bug#29303)
---
lisp/vc/vc-git.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index ed85603f82..fd5f5d5b63 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1428,7 +1428,8 @@ vc-git-grep
nil nil 'grep-history)
nil))
(t (let* ((regexp (grep-read-regexp))
- (files (grep-read-files regexp))
+ (files (concat "'" (replace-regexp-in-string " " "' '"
+ (grep-read-files regexp)) "'"))
(dir (read-directory-name "In directory: "
nil default-directory t)))
(list regexp files dir))))))
--
2.15.0
[Message part 3 (text/plain, inline)]
Robert
This bug report was last modified 7 years and 272 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.