From cff2f4606dfbc83f8e38a6b7a48eedcc47009a3b Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 13 Jul 2016 13:27:33 +0900 Subject: [PATCH] Escape meta chars in commands processed by shell * lisp/progmodes/grep.el (grep-compute-defaults): Quote braces in all commands to be passed to a shell (Bug#23959). --- lisp/progmodes/grep.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 2b44b58f24..f7f097b6be 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -543,7 +543,9 @@ This function is called from `compilation-filter-hook'." (let* ((host-id (intern (or (file-remote-p default-directory) "localhost"))) (host-defaults (assq host-id grep-host-defaults-alist)) - (defaults (assq nil grep-host-defaults-alist))) + (defaults (assq nil grep-host-defaults-alist)) + (quot-braces (shell-quote-argument "{}")) + (quot-scolon (shell-quote-argument ";"))) ;; There are different defaults on different hosts. They must be ;; computed for every host once. (dolist (setting '(grep-command grep-template @@ -637,9 +639,8 @@ This function is called from `compilation-filter-hook'." ""))) (cons (if (eq grep-find-use-xargs 'exec-plus) - (format "%s %s{} +" cmd0 null) - (format "%s {} %s%s" cmd0 null - (shell-quote-argument ";"))) + (format "%s %s%s +" cmd0 null quot-braces) + (format "%s %s %s%s" cmd0 quot-braces null quot-scolon)) (1+ (length cmd0))))) (t (format "%s . -type f -print | \"%s\" %s" @@ -655,12 +656,11 @@ This function is called from `compilation-filter-hook'." (format "%s -type f -print0 | \"%s\" -0 %s" find-program xargs-program gcmd)) ((eq grep-find-use-xargs 'exec) - (format "%s -type f -exec %s {} %s%s" - find-program gcmd null - (shell-quote-argument ";"))) + (format "%s -type f -exec %s %s %s%s" + find-program gcmd quot-braces null quot-scolon)) ((eq grep-find-use-xargs 'exec-plus) - (format "%s -type f -exec %s %s{} +" - find-program gcmd null)) + (format "%s -type f -exec %s %s%s +" + find-program gcmd null quot-braces)) (t (format "%s -type f -print | \"%s\" %s" find-program xargs-program gcmd)))))))) -- 2.39.2