Function: eshell/sudo
eshell/sudo is a byte-compiled function defined in em-tramp.el.gz.
Signature
(eshell/sudo &rest ARGS)
Documentation
Alias "sudo" to call Tramp.
Uses the system sudo through Tramp's sudo method.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/em-tramp.el.gz
(defun eshell/sudo (&rest args)
"Alias \"sudo\" to call Tramp.
Uses the system sudo through Tramp's sudo method."
(eshell-eval-using-options
"sudo" args
'((?h "help" nil nil "show this usage screen")
(?u "user" t user "execute a command as another USER")
(?s "shell" nil shell "start a shell instead of executing COMMAND")
:show-usage
:parse-leading-options-only
:usage "[(-u | --user) USER] (-s | --shell) | COMMAND
Execute a COMMAND as the superuser or another USER.")
(let ((dir (eshell--method-wrap-directory default-directory "sudo" user)))
(if shell
(throw 'eshell-replace-command
(eshell-parse-command "cd" (list dir)))
(throw 'eshell-external
(let ((default-directory dir))
(eshell-named-command (car args) (cdr args))))))))