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)
                    ;; 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)))