aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii1999-09-14 10:11:19 +0000
committerEli Zaretskii1999-09-14 10:11:19 +0000
commit8ee75d0316e120092505c76fea9a706348667b2e (patch)
treec25c9ff13789850e0f803c55028e45223180398b
parent5684cd6e1b754889c9c4f8b04c1a46ab78240b57 (diff)
downloademacs-8ee75d0316e120092505c76fea9a706348667b2e.tar.gz
emacs-8ee75d0316e120092505c76fea9a706348667b2e.zip
(shell-quote-argument): Quote argument with double
quotes for ms-dos.
-rw-r--r--lisp/subr.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 8ade8bc85de..c2e01916f98 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1148,8 +1148,19 @@ Unless optional argument INPLACE is non-nil, return a new string."
1148(defun shell-quote-argument (argument) 1148(defun shell-quote-argument (argument)
1149 "Quote an argument for passing as argument to an inferior shell." 1149 "Quote an argument for passing as argument to an inferior shell."
1150 (if (eq system-type 'ms-dos) 1150 (if (eq system-type 'ms-dos)
1151 ;; MS-DOS shells don't have quoting, so don't do any. 1151 ;; Quote using double quotes, but escape any existing quotes in
1152 argument 1152 ;; the argument with backslashes.
1153 (let ((result "")
1154 (start 0)
1155 end)
1156 (if (or (null (string-match "[^\"]" argument))
1157 (< (match-end 0) (length argument)))
1158 (while (string-match "[\"]" argument start)
1159 (setq end (match-beginning 0)
1160 result (concat result (substring argument start end)
1161 "\\" (substring argument end (1+ end)))
1162 start (1+ end))))
1163 (concat "\"" result (substring argument start) "\""))
1153 (if (eq system-type 'windows-nt) 1164 (if (eq system-type 'windows-nt)
1154 (concat "\"" argument "\"") 1165 (concat "\"" argument "\"")
1155 (if (equal argument "") 1166 (if (equal argument "")