Function: eshell-structure-basic-command

eshell-structure-basic-command is a byte-compiled function defined in esh-cmd.el.gz.

Signature

(eshell-structure-basic-command FUNC NAMES KEYWORD TEST BODY &optional ELSE)

Documentation

With TERMS, KEYWORD, and two NAMES, structure a basic command.

The first of NAMES should be the positive form, and the second the negative. It's not likely that users should ever need to call this function.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
(defun eshell-structure-basic-command (func names keyword test body
					    &optional else)
  "With TERMS, KEYWORD, and two NAMES, structure a basic command.
The first of NAMES should be the positive form, and the second the
negative.  It's not likely that users should ever need to call this
function."
  ;; If the test form begins with `eshell-convert', it means
  ;; something data-wise will be returned, and we should let
  ;; that determine the truth of the statement.
  (unless (eq (car test) 'eshell-convert)
    (setq test
	  `(progn ,test
                  (eshell-exit-success-p))))

  ;; should we reverse the sense of the test?  This depends
  ;; on the `names' parameter.  If it's the symbol nil, yes.
  ;; Otherwise, it can be a pair of strings; if the keyword
  ;; we're using matches the second member of that pair (a
  ;; list), we should reverse it.
  (if (or (eq names nil)
	  (and (listp names)
	       (string= keyword (cadr names))))
      (setq test `(not ,test)))

  ;; finally, create the form that represents this structured
  ;; command
  `(let ((eshell-command-body '(nil))
         (eshell-test-body '(nil)))
     (,func ,test ,body ,else)
     (eshell-close-handles
        eshell-last-command-status
        (list 'quote eshell-last-command-result))))