Function: eshell-do-pipelines-synchronously

eshell-do-pipelines-synchronously is a macro defined in esh-cmd.el.gz.

Signature

(eshell-do-pipelines-synchronously PIPELINE)

Documentation

Execute the commands in PIPELINE in sequence synchronously.

Output of each command is passed as input to the next one in the pipeline. This is used on systems where async subprocesses are not supported.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
(defmacro eshell-do-pipelines-synchronously (pipeline)
  "Execute the commands in PIPELINE in sequence synchronously.
Output of each command is passed as input to the next one in the pipeline.
This is used on systems where async subprocesses are not supported."
  (when (setq pipeline (cadr pipeline))
    `(progn
       ,(when (cdr pipeline)
          `(let ((output-marker ,(point-marker)))
             (eshell-set-output-handle ,eshell-output-handle
                                       'append output-marker)))
       ,(let ((head (car pipeline)))
          (if (memq (car head) '(let progn))
              (setq head (car (last head))))
          ;; FIXME: is deferrable significant here?
          (when (memq (car head) eshell-deferrable-commands)
            (ignore
             (setcar head
                     (intern-soft
                      (concat (symbol-name (car head)) "*"))))))
       ;; The last process in the pipe should get its handles
       ;; redirected as we found them before running the pipe.
       ,(if (null (cdr pipeline))
            '(progn
               (setq eshell-current-handles tail-handles)
               (setq eshell-in-pipeline-p nil)))
       (let ((result ,(car pipeline)))
         ;; tailproc gets the result of the last successful process in
         ;; the pipeline.
         (set tailproc (or result (symbol-value tailproc)))
         ,(if (cdr pipeline)
              `(eshell-do-pipelines-synchronously (quote ,(cdr pipeline))))
         result))))