comparison lisp/winnt.el @ 408:501cfd01ee6d r21-2-34

Import from CVS: tag r21-2-34
author cvs
date Mon, 13 Aug 2007 11:18:11 +0200
parents 2f8bb876ab1d
children 697ef44129c6
comparison
equal deleted inserted replaced
407:ed6218a7d4d3 408:501cfd01ee6d
83 (while (string-match "[?*]" name start) 83 (while (string-match "[?*]" name start)
84 (aset name (match-beginning 0) ?$) 84 (aset name (match-beginning 0) ?$)
85 (setq start (1+ (match-end 0)))) 85 (setq start (1+ (match-end 0))))
86 name)) 86 name))
87 87
88 ;;----------------------------------------------------------------------
89 ;; Quoting process args
90 ;;--------------------
91
92 (defun nt-quote-args-verbatim (args)
93 "Copy ARG list verbatim, separating each arg with space."
94 (mapconcat #'identity args " "))
95
96 (defun nt-quote-args-prefix-quote (prefix args)
97 (mapconcat (lambda (str)
98 (concat "\""
99 (mapconcat (lambda (ch)
100 (concat (if (eq ch ?\") prefix)
101 (char-to-string ch)))
102 str nil)
103 "\""))
104 args " "))
105
106 (defun nt-quote-args-backslash-quote (args)
107 "Place ARG list in quotes, prefixing quotes in args with backslashes."
108 (nt-quote-args-prefix-quote "\\" args))
109
110 (defun nt-quote-args-double-quote (args)
111 "Place ARG list in quotes, doubling quotes in args."
112 (nt-quote-args-prefix-quote "\"" args))
113
114 (defvar nt-quote-args-functions-alist
115 '(("^.?.?sh\\." . nt-quote-args-double-quote))
116 "An alist for determining proper argument quoting given executable file name.
117 Car of each cons must be a string, a regexp against which a file name sans
118 directory is matched. Cdr is a function symbol. The list is mathced in
119 forward order, and mathcing entry cdr's funcrion is called with a list of
120 strings, process arguments. It must return a string which is passed to
121 the newly created process.
122
123 If not found, then `nt-quote-args-verbatim' is called on the argument list.")
124
125 (defun nt-quote-process-args (args)
126 ;;Properly quote process ARGS for executing (car ARGS).
127 (let ((fname (file-name-nondirectory (car args)))
128 (alist nt-quote-args-functions-alist)
129 (case-fold-search nil)
130 (return-me nil)
131 (assoc nil))
132 (while (and alist
133 (null return-me))
134 (setq assoc (pop alist))
135 (if (string-match (car assoc) fname)
136 (setq return-me (funcall (cdr assoc) (cdr args)))))
137 (or return-me
138 (nt-quote-args-verbatim (cdr args)))))
139
140 ;;; winnt.el ends here 88 ;;; winnt.el ends here