changeset 25706:498eb90e1723

(shell-quote-argument): Quote argument with double quotes for ms-dos.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 14 Sep 1999 10:11:19 +0000
parents 1f109108fa7e
children 80e98999e8d9
files lisp/subr.el
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Tue Sep 14 08:33:24 1999 +0000
+++ b/lisp/subr.el	Tue Sep 14 10:11:19 1999 +0000
@@ -1148,8 +1148,19 @@
 (defun shell-quote-argument (argument)
   "Quote an argument for passing as argument to an inferior shell."
   (if (eq system-type 'ms-dos)
-      ;; MS-DOS shells don't have quoting, so don't do any.
-      argument
+      ;; Quote using double quotes, but escape any existing quotes in
+      ;; the argument with backslashes.
+      (let ((result "")
+	    (start 0)
+	    end)
+	(if (or (null (string-match "[^\"]" argument))
+		(< (match-end 0) (length argument)))
+	    (while (string-match "[\"]" argument start)
+	      (setq end (match-beginning 0)
+		    result (concat result (substring argument start end)
+				   "\\" (substring argument end (1+ end)))
+		    start (1+ end))))
+	(concat "\"" result (substring argument start) "\""))
     (if (eq system-type 'windows-nt)
 	(concat "\"" argument "\"")
       (if (equal argument "")