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 either a string or character. KIND should be the integer 0 if it's a character, or 1 if it's a string.

The SWITCH is then be matched against 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 either a string or character.  KIND should be the
integer 0 if it's a character, or 1 if it's a string.

The SWITCH is then be matched against 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* ((opts options)
	 found)
    (while opts
      (if (and (listp (car opts))
               (nth kind (car opts))
               (equal switch (nth kind (car opts))))
	  (progn
	    (eshell--set-option name ai (car opts) options opt-vals)
	    (setq found t opts nil))
	(setq opts (cdr opts))))
    (unless found
      (let ((extcmd (memq ':external options)))
	(when extcmd
	  (setq extcmd (eshell-search-path (cadr extcmd)))
	  (if extcmd
	      (throw 'eshell-ext-command extcmd)
            (error (if (characterp switch) "%s: unrecognized option -%c"
                     "%s: unrecognized option --%s")
                   name switch)))))))