diff options
| author | Jay Kamat | 2018-05-08 12:04:00 -0700 |
|---|---|---|
| committer | Noam Postavsky | 2018-06-03 12:48:14 -0400 |
| commit | 3ba5fc2bbec3f0f64c7afc1b05c9016710805463 (patch) | |
| tree | b9752fa378b61fd4f4b8f99e2fa959987cab2a1c | |
| parent | 0ac98cc6edf45e5acdf5d1bf79764745ec444381 (diff) | |
| download | emacs-3ba5fc2bbec3f0f64c7afc1b05c9016710805463.tar.gz emacs-3ba5fc2bbec3f0f64c7afc1b05c9016710805463.zip | |
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.
(cherry picked from commit 92a8230e49a65be48442ee95cf50c90514e48f99)
| -rw-r--r-- | lisp/eshell/esh-opt.el | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lisp/eshell/esh-opt.el b/lisp/eshell/esh-opt.el index 3af8fd7cacb..7d0b362b4c4 100644 --- a/lisp/eshell/esh-opt.el +++ b/lisp/eshell/esh-opt.el | |||
| @@ -244,26 +244,27 @@ switch is unrecognized." | |||
| 244 | options))) | 244 | options))) |
| 245 | (ai 0) arg | 245 | (ai 0) arg |
| 246 | (eshell--args args)) | 246 | (eshell--args args)) |
| 247 | (while (< ai (length args)) | 247 | (while (< ai (length eshell--args)) |
| 248 | (setq arg (nth ai args)) | 248 | (setq arg (nth ai eshell--args)) |
| 249 | (if (not (and (stringp arg) | 249 | (if (not (and (stringp arg) |
| 250 | (string-match "^-\\(-\\)?\\(.*\\)" arg))) | 250 | (string-match "^-\\(-\\)?\\(.*\\)" arg))) |
| 251 | (setq ai (1+ ai)) | 251 | (setq ai (1+ ai)) |
| 252 | (let* ((dash (match-string 1 arg)) | 252 | (let* ((dash (match-string 1 arg)) |
| 253 | (switch (match-string 2 arg))) | 253 | (switch (match-string 2 arg))) |
| 254 | (if (= ai 0) | 254 | (if (= ai 0) |
| 255 | (setq args (cdr args)) | 255 | (setq eshell--args (cdr eshell--args)) |
| 256 | (setcdr (nthcdr (1- ai) args) (nthcdr (1+ ai) args))) | 256 | (setcdr (nthcdr (1- ai) eshell--args) |
| 257 | (nthcdr (1+ ai) eshell--args))) | ||
| 257 | (if dash | 258 | (if dash |
| 258 | (if (> (length switch) 0) | 259 | (if (> (length switch) 0) |
| 259 | (eshell--process-option name switch 1 ai options opt-vals) | 260 | (eshell--process-option name switch 1 ai options opt-vals) |
| 260 | (setq ai (length args))) | 261 | (setq ai (length eshell--args))) |
| 261 | (let ((len (length switch)) | 262 | (let ((len (length switch)) |
| 262 | (index 0)) | 263 | (index 0)) |
| 263 | (while (< index len) | 264 | (while (< index len) |
| 264 | (eshell--process-option name (aref switch index) | 265 | (eshell--process-option name (aref switch index) |
| 265 | 0 ai options opt-vals) | 266 | 0 ai options opt-vals) |
| 266 | (setq index (1+ index)))))))) | 267 | (setq index (1+ index)))))))) |
| 267 | (nconc (mapcar #'cdr opt-vals) args))) | 268 | (nconc (mapcar #'cdr opt-vals) eshell--args))) |
| 268 | 269 | ||
| 269 | ;;; esh-opt.el ends here | 270 | ;;; esh-opt.el ends here |