Function: eshell--process-args

eshell--process-args is a byte-compiled function defined in esh-opt.el.gz.

Signature

(eshell--process-args NAME ARGS OPTIONS OPTION-SYMS)

Documentation

Process the given ARGS for the command NAME using OPTIONS.

OPTION-SYMS is a list of symbols that will hold the processed arguments.

Return a list of values corresponding to each element in OPTION-SYMS, followed by any additional positional arguments.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-opt.el.gz
(defun eshell--process-args (name args options option-syms)
  "Process the given ARGS for the command NAME using OPTIONS.
OPTION-SYMS is a list of symbols that will hold the processed arguments.

Return a list of values corresponding to each element in OPTION-SYMS,
followed by any additional positional arguments."
  (let* ((opt-vals (mapcar #'list option-syms))
         (ai 0) arg
         (eshell--args args)
         (pos-argument-found nil))
    (while (and (< ai (length eshell--args))
                ;; Abort if we saw the first pos argument and option is set
                (not (and pos-argument-found
                          (memq :parse-leading-options-only options))))
      (setq arg (nth ai eshell--args))
      (if (not (and (stringp arg)
                    ;; A string of length 1 can't be an option; (if
                    ;; it's "-", that generally means stdin).
                    (> (length arg) 1)
		    (string-match "^-\\(-\\)?\\(.*\\)" arg)))
          ;; Positional argument found, skip
	  (setq ai (1+ ai)
                pos-argument-found t)
        ;; dash or switch argument found, parse
	(let* ((dash (match-string 1 arg))
	       (switch (match-string 2 arg)))
	  (pop (nthcdr ai eshell--args))
	  (if dash
	      (if (> (length switch) 0)
		  (eshell--process-option name switch 1 ai options opt-vals)
		(setq ai (length eshell--args)))
	    (while (> (length switch) 0)
	      (setq switch (eshell--process-option name switch 0
                                                   ai options opt-vals)))))))
    (nconc (mapcar #'cdr opt-vals) eshell--args)))