aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-01-28 21:58:46 +0800
committerChong Yidong2012-01-28 21:58:46 +0800
commit93376c5baf50aab8e5095c083ad11dcf9caff36a (patch)
tree5c0bce5e5ae9ddeece76c77c99af0f5d67e544ff
parent8c6e1920922a40d25b440478af6ea5c52ebfdf06 (diff)
downloademacs-93376c5baf50aab8e5095c083ad11dcf9caff36a.tar.gz
emacs-93376c5baf50aab8e5095c083ad11dcf9caff36a.zip
Quote file name commands in eshell.
* lisp/eshell/esh-arg.el (eshell-quote-argument): New function. * lisp/eshell/esh-ext.el (eshell-invoke-batch-file): * lisp/eshell/em-unix.el (eshell/cat, eshell/du): Use it to quote the first arg to eshell-parse-command. Fixes: debbugs:10523
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/eshell/em-unix.el4
-rw-r--r--lisp/eshell/esh-arg.el12
-rw-r--r--lisp/eshell/esh-ext.el4
4 files changed, 25 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c374c71db38..8bde5f91046 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-01-28 Chong Yidong <cyd@gnu.org>
2
3 * eshell/esh-arg.el (eshell-quote-argument): New function.
4
5 * eshell/esh-ext.el (eshell-invoke-batch-file):
6 * eshell/em-unix.el (eshell/cat, eshell/du): Use it to quote the
7 first arg to eshell-parse-command (Bug#10523).
8
12012-01-28 Drew Adams <drew.adams@oracle.com> 92012-01-28 Drew Adams <drew.adams@oracle.com>
2 10
3 * net/ange-ftp.el (ange-ftp-canonize-filename): Check, that 11 * net/ange-ftp.el (ange-ftp-canonize-filename): Check, that
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index 296e2ee8b24..6ac53e30e86 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -599,7 +599,7 @@ symlink, then revert to the system's definition of cat."
599 (let ((ext-cat (eshell-search-path "cat"))) 599 (let ((ext-cat (eshell-search-path "cat")))
600 (if ext-cat 600 (if ext-cat
601 (throw 'eshell-replace-command 601 (throw 'eshell-replace-command
602 (eshell-parse-command ext-cat args)) 602 (eshell-parse-command (eshell-quote-argument ext-cat) args))
603 (if eshell-in-pipeline-p 603 (if eshell-in-pipeline-p
604 (error "Eshell's `cat' does not work in pipelines") 604 (error "Eshell's `cat' does not work in pipelines")
605 (error "Eshell's `cat' cannot display one of the files given")))) 605 (error "Eshell's `cat' cannot display one of the files given"))))
@@ -855,7 +855,7 @@ external command."
855 (file-remote-p (expand-file-name arg) 'method) "ftp") 855 (file-remote-p (expand-file-name arg) 'method) "ftp")
856 (throw 'have-ange-path t)))))) 856 (throw 'have-ange-path t))))))
857 (throw 'eshell-replace-command 857 (throw 'eshell-replace-command
858 (eshell-parse-command ext-du args)) 858 (eshell-parse-command (eshell-quote-argument ext-du) args))
859 (eshell-eval-using-options 859 (eshell-eval-using-options
860 "du" args 860 "du" args
861 '((?a "all" nil show-all 861 '((?a "all" nil show-all
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el
index 8143f2d65be..ad52a5d4a71 100644
--- a/lisp/eshell/esh-arg.el
+++ b/lisp/eshell/esh-arg.el
@@ -202,6 +202,18 @@ If POS is nil, the location of point is checked."
202 (or (= pos (point-max)) 202 (or (= pos (point-max))
203 (memq (char-after pos) eshell-delimiter-argument-list)))) 203 (memq (char-after pos) eshell-delimiter-argument-list))))
204 204
205(defun eshell-quote-argument (string)
206 "Return STRING with magic characters quoted.
207Magic characters are those in `eshell-special-chars-outside-quoting'."
208 (let ((index 0))
209 (mapconcat (lambda (c)
210 (prog1
211 (or (eshell-quote-backslash string index)
212 (char-to-string c))
213 (setq index (1+ index))))
214 string
215 "")))
216
205;; Argument parsing 217;; Argument parsing
206 218
207(defun eshell-parse-arguments (beg end) 219(defun eshell-parse-arguments (beg end)
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index a33ccc82978..cf57a1dce79 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -108,7 +108,9 @@ wholly ignored."
108 ;; argument... 108 ;; argument...
109 (setcar args (subst-char-in-string ?/ ?\\ (car args))) 109 (setcar args (subst-char-in-string ?/ ?\\ (car args)))
110 (throw 'eshell-replace-command 110 (throw 'eshell-replace-command
111 (eshell-parse-command eshell-windows-shell-file (cons "/c" args)))) 111 (eshell-parse-command
112 (eshell-quote-argument eshell-windows-shell-file)
113 (cons "/c" args))))
112 114
113(defcustom eshell-interpreter-alist 115(defcustom eshell-interpreter-alist
114 (if (eshell-under-windows-p) 116 (if (eshell-under-windows-p)