diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index ccc58e6773..85e872bfc2 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -611,6 +611,11 @@ grep-hello-file (write-region "Copyright\n" nil result)) result)) +(defun grep-shell-quote-argument (argument) + (let ((system-type + (if (file-remote-p default-directory) 'not-windows system-type))) + (shell-quote-argument argument))) + ;;;###autoload (defun grep-compute-defaults () "Compute the defaults for the `grep' command. @@ -636,8 +641,8 @@ grep-compute-defaults (intern (or (file-remote-p default-directory) "localhost"))) (host-defaults (assq host-id grep-host-defaults-alist)) (defaults (assq nil grep-host-defaults-alist)) - (quot-braces (shell-quote-argument "{}")) - (quot-scolon (shell-quote-argument ";"))) + (quot-braces (grep-shell-quote-argument "{}")) + (quot-scolon (grep-shell-quote-argument ";"))) ;; There are different defaults on different hosts. They must be ;; computed for every host once. (dolist (setting '(grep-command grep-template @@ -820,7 +825,7 @@ grep-tag-default (defun grep-default-command () "Compute the default grep command for \\[universal-argument] \\[grep] to offer." - (let ((tag-default (shell-quote-argument (grep-tag-default))) + (let ((tag-default (grep-shell-quote-argument (grep-tag-default))) ;; This a regexp to match single shell arguments. ;; Could someone please add comments explaining it? (sh-arg-re @@ -963,7 +968,7 @@ grep-expand-keywords ("" . files) ("" . (null-device)) ("" . excl) - ("" . (shell-quote-argument (or regexp "")))) + ("" . (grep-shell-quote-argument (or regexp "")))) "List of substitutions performed by `grep-expand-template'. If car of an element matches, the cdr is evalled in order to get the substitution string. @@ -1134,10 +1139,10 @@ lgrep (mapconcat (lambda (ignore) (cond ((stringp ignore) - (shell-quote-argument ignore)) + (grep-shell-quote-argument ignore)) ((consp ignore) (and (funcall (car ignore) dir) - (shell-quote-argument + (grep-shell-quote-argument (cdr ignore)))))) grep-find-ignored-files " --exclude="))) @@ -1245,44 +1250,44 @@ rgrep-default-command (grep-expand-template grep-find-template regexp - (concat (shell-quote-argument "(") + (concat (grep-shell-quote-argument "(") " " find-name-arg " " (mapconcat - #'shell-quote-argument + #'grep-shell-quote-argument (split-string files) (concat " -o " find-name-arg " ")) " " - (shell-quote-argument ")")) + (grep-shell-quote-argument ")")) dir (concat (and grep-find-ignored-directories (concat "-type d " - (shell-quote-argument "(") - ;; we should use shell-quote-argument here + (grep-shell-quote-argument "(") + ;; we should use grep-shell-quote-argument here " -path " - (mapconcat (lambda (d) (shell-quote-argument (concat "*/" d))) + (mapconcat (lambda (d) (grep-shell-quote-argument (concat "*/" d))) (rgrep-find-ignored-directories dir) " -o -path ") " " - (shell-quote-argument ")") + (grep-shell-quote-argument ")") " -prune -o ")) (and grep-find-ignored-files - (concat (shell-quote-argument "!") " -type d " - (shell-quote-argument "(") - ;; we should use shell-quote-argument here + (concat (grep-shell-quote-argument "!") " -type d " + (grep-shell-quote-argument "(") + ;; we should use grep-shell-quote-argument here " -name " (mapconcat (lambda (ignore) (cond ((stringp ignore) - (shell-quote-argument ignore)) + (grep-shell-quote-argument ignore)) ((consp ignore) (and (funcall (car ignore) dir) - (shell-quote-argument + (grep-shell-quote-argument (cdr ignore)))))) grep-find-ignored-files " -o -name ") " " - (shell-quote-argument ")") + (grep-shell-quote-argument ")") " -prune -o "))))) (defun grep-find-toggle-abbreviation ()