mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-02-03 20:24:29 +00:00
esh-opt.el: Fix improper parsing of first argument (Bug#28323)
Examples of broken behavior: sudo -u root whoami Outputs: -u ls -I '*.txt' /dev/null Errors with: *.txt: No such file or directory * lisp/eshell/esh-opt.el (eshell--process-args): Refactor usage of args to eshell--args, as we rely on modifications from eshell--process-option and vice versa. These modifications were not being propogated in the (if (= ai 0)) case, since popping the first element of a list doesn't destructively modify the underlying list object.
This commit is contained in:
parent
3cc714d102
commit
92a8230e49
@ -246,26 +246,27 @@ switch is unrecognized."
|
|||||||
options)))
|
options)))
|
||||||
(ai 0) arg
|
(ai 0) arg
|
||||||
(eshell--args args))
|
(eshell--args args))
|
||||||
(while (< ai (length args))
|
(while (< ai (length eshell--args))
|
||||||
(setq arg (nth ai args))
|
(setq arg (nth ai eshell--args))
|
||||||
(if (not (and (stringp arg)
|
(if (not (and (stringp arg)
|
||||||
(string-match "^-\\(-\\)?\\(.*\\)" arg)))
|
(string-match "^-\\(-\\)?\\(.*\\)" arg)))
|
||||||
(setq ai (1+ ai))
|
(setq ai (1+ ai))
|
||||||
(let* ((dash (match-string 1 arg))
|
(let* ((dash (match-string 1 arg))
|
||||||
(switch (match-string 2 arg)))
|
(switch (match-string 2 arg)))
|
||||||
(if (= ai 0)
|
(if (= ai 0)
|
||||||
(setq args (cdr args))
|
(setq eshell--args (cdr eshell--args))
|
||||||
(setcdr (nthcdr (1- ai) args) (nthcdr (1+ ai) args)))
|
(setcdr (nthcdr (1- ai) eshell--args)
|
||||||
|
(nthcdr (1+ ai) eshell--args)))
|
||||||
(if dash
|
(if dash
|
||||||
(if (> (length switch) 0)
|
(if (> (length switch) 0)
|
||||||
(eshell--process-option name switch 1 ai options opt-vals)
|
(eshell--process-option name switch 1 ai options opt-vals)
|
||||||
(setq ai (length args)))
|
(setq ai (length eshell--args)))
|
||||||
(let ((len (length switch))
|
(let ((len (length switch))
|
||||||
(index 0))
|
(index 0))
|
||||||
(while (< index len)
|
(while (< index len)
|
||||||
(eshell--process-option name (aref switch index)
|
(eshell--process-option name (aref switch index)
|
||||||
0 ai options opt-vals)
|
0 ai options opt-vals)
|
||||||
(setq index (1+ index))))))))
|
(setq index (1+ index))))))))
|
||||||
(nconc (mapcar #'cdr opt-vals) args)))
|
(nconc (mapcar #'cdr opt-vals) eshell--args)))
|
||||||
|
|
||||||
;;; esh-opt.el ends here
|
;;; esh-opt.el ends here
|
||||||
|
Loading…
x
Reference in New Issue
Block a user