Function: eshell-create-handles

eshell-create-handles is a byte-compiled function defined in esh-io.el.gz.

Signature

(eshell-create-handles STDOUT OUTPUT-MODE &optional STDERR ERROR-MODE)

Documentation

Create a new set of file handles for a command.

The default target for standard output and standard error will go to STDOUT and STDERR, respectively. OUTPUT-MODE and ERROR-MODE are either overwrite, append or insert; a nil value of mode defaults to insert.

The result is a vector of file handles. Each handle is of the form:

  ((TARGETS . REF-COUNT) DEFAULT)

TARGETS is a list of destinations for output. REF-COUNT is the number of references to this handle (initially 1); see eshell-protect-handles and eshell-close-handles. DEFAULT is non-nil if handle has its initial default value (always t after calling this function).

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-io.el.gz
(defun eshell-create-handles
  (stdout output-mode &optional stderr error-mode)
  "Create a new set of file handles for a command.
The default target for standard output and standard error will
go to STDOUT and STDERR, respectively.  OUTPUT-MODE and
ERROR-MODE are either `overwrite', `append' or `insert'; a nil
value of mode defaults to `insert'.

The result is a vector of file handles.  Each handle is of the form:

  ((TARGETS . REF-COUNT) DEFAULT)

TARGETS is a list of destinations for output.  REF-COUNT is the
number of references to this handle (initially 1); see
`eshell-protect-handles' and `eshell-close-handles'.  DEFAULT is
non-nil if handle has its initial default value (always t after
calling this function)."
  (let* ((handles (make-vector eshell-number-of-handles nil))
         (output-target
          (let ((target (eshell-get-target stdout output-mode)))
            (cons (when target (list target)) 1)))
         (error-target
          (if stderr
              (let ((target (eshell-get-target stderr error-mode)))
                (cons (when target (list target)) 1))
            (incf (cdr output-target))
            output-target)))
    (aset handles eshell-output-handle (list output-target t))
    (aset handles eshell-error-handle (list error-target t))
    handles))