Raise an error from 'eval-eval-using-options' for unknown options

* lisp/eshell/em-basic.el (eshell/echo): Add -E option.

* lisp/eshell/esh-opt.el (eshell--process-option): Raise an error if
an unknown option is encountered, even when :external is nil.

* test/lisp/eshell/esh-opt-tests.el (esh-opt-process-args-test)
(test-eshell-eval-using-options): Add test cases for this.
This commit is contained in:
Jim Porter 2022-01-19 18:59:23 -08:00 committed by Lars Ingebrigtsen
parent a133af7c7f
commit 90de226e21
3 changed files with 79 additions and 32 deletions

View file

@ -113,11 +113,16 @@ or `eshell-printn' for display."
"Implementation of `echo'. See `eshell-plain-echo-behavior'."
(eshell-eval-using-options
"echo" args
'((?n nil (nil) output-newline "do not output the trailing newline")
(?N nil (t) output-newline "terminate with a newline")
(?h "help" nil nil "output this help screen")
'((?n nil (nil) output-newline
"do not output the trailing newline")
(?N nil (t) output-newline
"terminate with a newline")
(?E nil nil _disable-escapes
"don't interpret backslash escapes (default)")
(?h "help" nil nil
"output this help screen")
:preserve-args
:usage "[-n | -N] [object]")
:usage "[OPTION]... [OBJECT]...")
(if eshell-plain-echo-behavior
(eshell-echo args (if output-newline (car output-newline) t))
;; In Emacs 28.1 and earlier, "-n" was used to add a newline to

View file

@ -257,12 +257,12 @@ triggered to say that the switch is unrecognized."
remaining
(let ((extcmd (memq ':external options)))
(when extcmd
(setq extcmd (eshell-search-path (cadr extcmd)))
(if extcmd
(throw 'eshell-ext-command extcmd)
(error (if (characterp (car switch)) "%s: unrecognized option -%c"
"%s: unrecognized option --%s")
name (car switch))))))))
(setq extcmd (eshell-search-path (cadr extcmd))))
(if extcmd
(throw 'eshell-ext-command extcmd)
(error (if (characterp (car switch)) "%s: unrecognized option -%c"
"%s: unrecognized option --%s")
name (car switch)))))))
(defun eshell--process-args (name args options)
"Process the given ARGS using OPTIONS."