aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Rumney2006-09-25 23:03:39 +0000
committerJason Rumney2006-09-25 23:03:39 +0000
commit4bbf6b4158630ee19cbe1a726739cd1bcf6e4cf1 (patch)
tree1aface1e80524d46f6f7f7bfa69e8bc4a23de447
parentdaea741e29f53d660cd4a476651cb1008b0066a6 (diff)
downloademacs-4bbf6b4158630ee19cbe1a726739cd1bcf6e4cf1.tar.gz
emacs-4bbf6b4158630ee19cbe1a726739cd1bcf6e4cf1.zip
(shell-quote-argument): Use DOS logic for Windows shells with DOS semantics.
-rw-r--r--lisp/subr.el27
1 files changed, 13 insertions, 14 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index daaacaf75a1..45decd63924 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2053,7 +2053,8 @@ a system-dependent default device name is used."
2053 2053
2054(defun shell-quote-argument (argument) 2054(defun shell-quote-argument (argument)
2055 "Quote an argument for passing as argument to an inferior shell." 2055 "Quote an argument for passing as argument to an inferior shell."
2056 (if (eq system-type 'ms-dos) 2056 (if (or (eq system-type 'ms-dos)
2057 (and (eq system-type 'windows-nt) (w32-shell-dos-semantics)))
2057 ;; Quote using double quotes, but escape any existing quotes in 2058 ;; Quote using double quotes, but escape any existing quotes in
2058 ;; the argument with backslashes. 2059 ;; the argument with backslashes.
2059 (let ((result "") 2060 (let ((result "")
@@ -2067,19 +2068,17 @@ a system-dependent default device name is used."
2067 "\\" (substring argument end (1+ end))) 2068 "\\" (substring argument end (1+ end)))
2068 start (1+ end)))) 2069 start (1+ end))))
2069 (concat "\"" result (substring argument start) "\"")) 2070 (concat "\"" result (substring argument start) "\""))
2070 (if (eq system-type 'windows-nt) 2071 (if (equal argument "")
2071 (concat "\"" argument "\"") 2072 "''"
2072 (if (equal argument "") 2073 ;; Quote everything except POSIX filename characters.
2073 "''" 2074 ;; This should be safe enough even for really weird shells.
2074 ;; Quote everything except POSIX filename characters. 2075 (let ((result "") (start 0) end)
2075 ;; This should be safe enough even for really weird shells. 2076 (while (string-match "[^-0-9a-zA-Z_./]" argument start)
2076 (let ((result "") (start 0) end) 2077 (setq end (match-beginning 0)
2077 (while (string-match "[^-0-9a-zA-Z_./]" argument start) 2078 result (concat result (substring argument start end)
2078 (setq end (match-beginning 0) 2079 "\\" (substring argument end (1+ end)))
2079 result (concat result (substring argument start end) 2080 start (1+ end)))
2080 "\\" (substring argument end (1+ end))) 2081 (concat result (substring argument start))))))
2081 start (1+ end)))
2082 (concat result (substring argument start)))))))
2083 2082
2084(defun string-or-null-p (object) 2083(defun string-or-null-p (object)
2085 "Return t if OBJECT is a string or nil. 2084 "Return t if OBJECT is a string or nil.