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)

Documentation

Process the given ARGS using OPTIONS.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-opt.el.gz
(defun eshell--process-args (name args options)
  "Process the given ARGS using OPTIONS."
  (let* ((seen ())
         (opt-vals (delq nil (mapcar (lambda (opt)
                                       (when (listp opt)
                                         (let ((sym (nth 3 opt)))
                                           (when (and sym (not (memq sym seen)))
					     (push sym seen)
                                             (list sym)))))
				     options)))
         (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)
		    (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)))
	    (let ((len (length switch))
		  (index 0))
	      (while (< index len)
		(eshell--process-option name (aref switch index)
                                        0 ai options opt-vals)
		(setq index (1+ index))))))))
    (nconc (mapcar #'cdr opt-vals) eshell--args)))