# HG changeset patch # User Michael Albinus # Date 1259525429 0 # Node ID 12c2a6b10cafe1f644a5a943d7d66d54727c61b0 # Parent 334a4954c17e581053441959d72b29d42756432f * eshell/em-unix (eshell/whoami): Make it a defun but a defalias. (eshell/su): Flatten args. Apply better args parsing. Use "cd". (eshell/sudo): Flatten args. Let-bind `default-directory'. diff -r 334a4954c17e -r 12c2a6b10caf lisp/eshell/em-unix.el --- a/lisp/eshell/em-unix.el Sun Nov 29 20:05:23 2009 +0000 +++ b/lisp/eshell/em-unix.el Sun Nov 29 20:10:29 2009 +0000 @@ -955,7 +955,9 @@ (eshell-stringify-list (eshell-flatten-list (cdr time-args)))))))) -(defalias 'eshell/whoami 'user-login-name) +(defun eshell/whoami (&rest args) + "Make \"whoami\" Tramp aware." + (or (file-remote-p default-directory 'user) (user-login-name))) (defvar eshell-diff-window-config nil) @@ -1046,8 +1048,8 @@ (defun eshell/su (&rest args) "Alias \"su\" to call Tramp." - (let ((-login (member "-" args)) ;; not handled by `eshell-eval-using-options' - login) + (setq args (eshell-stringify-list (eshell-flatten-list args))) + (let (login) (eshell-eval-using-options "sudo" args '((?h "help" nil nil "show this usage screen") @@ -1061,8 +1063,9 @@ "localhost")) (dir (or (file-remote-p default-directory 'localname) default-directory))) - (if (or login -login) (setq dir "~/")) - (if (stringp (car args)) (setq user (car args))) + (eshell-for arg args + (if (string-equal arg "-") (setq login t) (setq user arg))) + (if login (setq dir "~/")) (if (and (file-remote-p default-directory) (not (string-equal user (file-remote-p default-directory 'user)))) @@ -1070,12 +1073,13 @@ 'tramp-default-proxies-alist (list host user (file-remote-p default-directory)))) (eshell-parse-command - "eshell/cd" (list (format "/su:%s@%s:%s" user host dir)))))))) + "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." + (setq args (eshell-stringify-list (eshell-flatten-list args))) (let (user) (eshell-eval-using-options "sudo" args @@ -1089,15 +1093,15 @@ (host (or (file-remote-p default-directory 'host) "localhost")) (dir (or (file-remote-p default-directory 'localname) - default-directory)) - (default-directory (format "/sudo:%s@%s:%s" user host dir))) + default-directory))) (if (and (file-remote-p default-directory) (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-named-command (car args) (cdr args))))))) + (let ((default-directory (format "/sudo:%s@%s:%s" user host dir))) + (eshell-named-command (car args) (cdr args)))))))) (put 'eshell/sudo 'eshell-no-numeric-conversions t)