Function: eshell--process-option
eshell--process-option is a byte-compiled function defined in
esh-opt.el.gz.
Signature
(eshell--process-option NAME SWITCH KIND AI OPTIONS OPT-VALS)
Documentation
For NAME, process SWITCH (of type KIND), from args at index AI.
The SWITCH will be looked up in the set of OPTIONS.
SWITCH should be a string starting with the option to process, possibly followed by its value, e.g. "u" or "uUSER". KIND should be the integer 0 if it's a short option, or 1 if it's a long option.
The SWITCH is then be matched against OPTIONS. If KIND is 0 and the SWITCH matches an option that doesn't take a value, return the remaining characters in SWITCH to be processed later as further short options.
If no matching handler is found, and an :external command is defined
(and available), it will be called; otherwise, an error will be
triggered to say that the switch is unrecognized.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-opt.el.gz
(defun eshell--process-option (name switch kind ai options opt-vals)
"For NAME, process SWITCH (of type KIND), from args at index AI.
The SWITCH will be looked up in the set of OPTIONS.
SWITCH should be a string starting with the option to process,
possibly followed by its value, e.g. \"u\" or \"uUSER\". KIND should
be the integer 0 if it's a short option, or 1 if it's a long option.
The SWITCH is then be matched against OPTIONS. If KIND is 0 and the
SWITCH matches an option that doesn't take a value, return the
remaining characters in SWITCH to be processed later as further short
options.
If no matching handler is found, and an :external command is defined
(and available), it will be called; otherwise, an error will be
triggered to say that the switch is unrecognized."
(let ((switch (eshell--split-switch switch kind))
(opts options)
found remaining)
(while opts
(if (and (listp (car opts))
(equal (car switch) (nth kind (car opts))))
(progn
(setq remaining (eshell--set-option name ai (car opts)
(cdr switch) options opt-vals))
(when (and remaining (eq kind 1))
(error "%s: option --%s doesn't allow an argument"
name (car switch)))
(setq found t opts nil))
(setq opts (cdr opts))))
(if found
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)))))))