diff options
author | Jim Porter <jporterbugs@gmail.com> | 2022-01-24 21:08:50 -0800 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-01-25 13:28:48 +0100 |
commit | 44ffd6a825300fec5e492805bb105d2c8c3d0c1c (patch) | |
tree | 8795aa3284e7fd1f51ce4a13d92484d2350092bf /lisp/eshell | |
parent | dea24a0f7d4ae42fae912dd724a770678054989a (diff) | |
download | emacs-44ffd6a825300fec5e492805bb105d2c8c3d0c1c.tar.gz |
Treat "-" as a positional arg in 'eshell-eval-using-options'
* lisp/eshell/esh-opt.el (eshell--process-args): Treat "-" as a
positional arg.
* lisp/eshell/em-tramp.el (eshell/su): Simplify checking for "-".
* test/lisp/eshell/esh-opt-tests.el
(esh-opt-test/eval-using-options-stdin): New test.
Diffstat (limited to 'lisp/eshell')
-rw-r--r-- | lisp/eshell/em-tramp.el | 9 | ||||
-rw-r--r-- | lisp/eshell/esh-opt.el | 9 |
2 files changed, 8 insertions, 10 deletions
diff --git a/lisp/eshell/em-tramp.el b/lisp/eshell/em-tramp.el index 791458822da..2afd4fe066a 100644 --- a/lisp/eshell/em-tramp.el +++ b/lisp/eshell/em-tramp.el @@ -57,13 +57,12 @@ (autoload 'eshell-parse-command "esh-cmd") -(defun eshell/su (&rest arguments) +(defun eshell/su (&rest args) "Alias \"su\" to call TRAMP. Uses the system su through TRAMP's su method." - (setq arguments (eshell-stringify-list (flatten-tree arguments))) (eshell-eval-using-options - "su" arguments + "su" args '((?h "help" nil nil "show this usage screen") (?l "login" nil login "provide a login environment") (? nil nil login "provide a login environment") @@ -77,10 +76,6 @@ Become another USER during a login session.") (prefix (file-remote-p default-directory))) (dolist (arg args) (if (string-equal arg "-") (setq login t) (setq user arg))) - ;; `eshell-eval-using-options' tries to handle "-" as a - ;; short option; double-check whether the original - ;; arguments include it. - (when (member "-" arguments) (setq login t)) (when login (setq dir "~/")) (if (and prefix (or diff --git a/lisp/eshell/esh-opt.el b/lisp/eshell/esh-opt.el index 8c29fff8096..0961e214f4f 100644 --- a/lisp/eshell/esh-opt.el +++ b/lisp/eshell/esh-opt.el @@ -283,6 +283,9 @@ triggered to say that the switch is unrecognized." (memq :parse-leading-options-only options)))) (setq arg (nth ai eshell--args)) (if (not (and (stringp arg) + ;; A string of length 1 can't be an option; (if + ;; it's "-", that generally means stdin). + (> (length arg) 1) (string-match "^-\\(-\\)?\\(.*\\)" arg))) ;; Positional argument found, skip (setq ai (1+ ai) @@ -295,9 +298,9 @@ triggered to say that the switch is unrecognized." (if (> (length switch) 0) (eshell--process-option name switch 1 ai options opt-vals) (setq ai (length eshell--args))) - (while (> (length switch) 0) - (setq switch (eshell--process-option name switch 0 - ai options opt-vals))))))) + (while (> (length switch) 0) + (setq switch (eshell--process-option name switch 0 + ai options opt-vals))))))) (nconc (mapcar #'cdr opt-vals) eshell--args))) (provide 'esh-opt) |