diff options
author | Eli Zaretskii <[email protected]> | 1999-09-14 10:11:19 +0000 |
---|---|---|
committer | Eli Zaretskii <[email protected]> | 1999-09-14 10:11:19 +0000 |
commit | 8ee75d0316e120092505c76fea9a706348667b2e (patch) | |
tree | c25c9ff13789850e0f803c55028e45223180398b /lisp/subr.el | |
parent | 5684cd6e1b754889c9c4f8b04c1a46ab78240b57 (diff) |
(shell-quote-argument): Quote argument with double
quotes for ms-dos.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 8ade8bc85d..c2e01916f9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1148,8 +1148,19 @@ Unless optional argument INPLACE is non-nil, return a new string." (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 "") |