branch: externals/urgrep
commit c7a3cc5b30cdca7a9e96409b6fbcf0094c5d2cad
Author: Jim Porter <jporterb...@gmail.com>
Commit: Jim Porter <jporterb...@gmail.com>

    Be less aggressive with shell-quoting on MS Windows
---
 urgrep.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/urgrep.el b/urgrep.el
index 074b30479e..242afd1c0f 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -128,6 +128,16 @@
                        (string= vc-backend-name tool-vc-backend)))
           (cl-return tool))))))
 
+(defun urgrep--maybe-shell-quote-argument (argument)
+  "Quote ARGUMENT if needed for passing to an inferior shell.
+This works as `shell-quote-argument', but avoids quoting unnecessarily
+for MS shells."
+  (if (and (or (eq system-type 'ms-dos)
+               (and (eq system-type 'windows-nt) (w32-shell-dos-semantics)))
+           (not (string-match "[^-0-9a-zA-Z_./=]" argument)))
+      argument
+    (shell-quote-argument argument)))
+
 (cl-defun urgrep-command (query &rest rest &key tool (group t) regexp
                                 (context 0))
   (let* ((tool (or tool (urgrep-get-tool)))
@@ -152,7 +162,7 @@
           (setq arguments (append (list context-arg) arguments)))
         ;; FIXME: Inside compile and dired buffers, `shell-quote-argument'
         ;; doesn't handle TRAMP right...
-        (mapconcat #'shell-quote-argument
+        (mapconcat #'urgrep--maybe-shell-quote-argument
                    (append `(,executable) pre-args arguments `(,query))
                    " ")))))
 

Reply via email to