summaryrefslogtreecommitdiff
path: root/lisp/eshell/em-unix.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2012-07-16 13:42:01 +0200
committerMichael Albinus <michael.albinus@gmx.de>2012-07-16 13:42:01 +0200
commit9328d9aabae2f45f82b59aad5214a3f13ee1b2a1 (patch)
tree918a667537a03133a325cc8cc9e1f1b0128d1117 /lisp/eshell/em-unix.el
parent5d127af98d11f54f9c75e28dcd8c3e26e42d50a8 (diff)
downloademacs-9328d9aabae2f45f82b59aad5214a3f13ee1b2a1.tar.gz
* eshell/em-ls.el (eshell/ls): Use `apply'.
* eshell/em-unix.el (eshell/su, eshell/sudo): Apply Tramp's ad-hoc multi-hops, instead of Tramp internals.
Diffstat (limited to 'lisp/eshell/em-unix.el')
-rw-r--r--lisp/eshell/em-unix.el47
1 files changed, 24 insertions, 23 deletions
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index ddba5a6520a..35f7a0a9e3d 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -1037,12 +1037,8 @@ Show wall-clock time elapsed during execution of COMMAND.")
(put 'eshell/occur 'eshell-no-numeric-conversions t)
-;; Pacify the byte-compiler.
-(defvar tramp-default-proxies-alist)
-
(defun eshell/su (&rest args)
"Alias \"su\" to call Tramp."
- (require 'tramp)
(setq args (eshell-stringify-list (eshell-flatten-list args)))
(let ((orig-args (copy-tree args)))
(eshell-eval-using-options
@@ -1057,29 +1053,29 @@ Become another USER during a login session.")
(host (or (file-remote-p default-directory 'host)
"localhost"))
(dir (or (file-remote-p default-directory 'localname)
- (expand-file-name default-directory))))
+ (expand-file-name default-directory)))
+ (prefix (file-remote-p default-directory)))
(dolist (arg args)
(if (string-equal arg "-") (setq login t) (setq user arg)))
;; `eshell-eval-using-options' does not handle "-".
(if (member "-" orig-args) (setq login t))
(if login (setq dir "~/"))
- (if (and (file-remote-p default-directory)
+ (if (and prefix
(or
(not (string-equal
"su" (file-remote-p default-directory 'method)))
(not (string-equal
user (file-remote-p default-directory 'user)))))
- (add-to-list
- 'tramp-default-proxies-alist
- (list host user (file-remote-p default-directory))))
- (eshell-parse-command
- "cd" (list (format "/su:%s@%s:%s" user host dir))))))))
+ (eshell-parse-command
+ "cd" (list (format "%s|su:%s@%s:%s"
+ (substring prefix 0 -1) user host dir)))
+ (eshell-parse-command
+ "cd" (list (format "/su:%s@%s:%s" user host dir)))))))))
(put 'eshell/su 'eshell-no-numeric-conversions t)
(defun eshell/sudo (&rest args)
"Alias \"sudo\" to call Tramp."
- (require 'tramp)
(setq args (eshell-stringify-list (eshell-flatten-list args)))
(let ((orig-args (copy-tree args)))
(eshell-eval-using-options
@@ -1094,21 +1090,26 @@ Execute a COMMAND as the superuser or another USER.")
(host (or (file-remote-p default-directory 'host)
"localhost"))
(dir (or (file-remote-p default-directory 'localname)
- (expand-file-name default-directory))))
+ (expand-file-name default-directory)))
+ (prefix (file-remote-p default-directory)))
;; `eshell-eval-using-options' reads options of COMMAND.
(while (and (stringp (car orig-args))
(member (car orig-args) '("-u" "--user")))
(setq orig-args (cddr orig-args)))
- (if (and (file-remote-p default-directory)
- (or
- (not (string-equal
- "sudo" (file-remote-p default-directory 'method)))
- (not (string-equal
- user (file-remote-p default-directory 'user)))))
- (add-to-list
- 'tramp-default-proxies-alist
- (list host user (file-remote-p default-directory))))
- (let ((default-directory (format "/sudo:%s@%s:%s" user host dir)))
+ (let ((default-directory
+ (if (and prefix
+ (or
+ (not
+ (string-equal
+ "sudo"
+ (file-remote-p default-directory 'method)))
+ (not
+ (string-equal
+ user
+ (file-remote-p default-directory 'user)))))
+ (format "%s|sudo:%s@%s:%s"
+ (substring prefix 0 -1) user host dir)
+ (format "/sudo:%s@%s:%s" user host dir))))
(eshell-named-command (car orig-args) (cdr orig-args))))))))
(put 'eshell/sudo 'eshell-no-numeric-conversions t)