[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master dd2438eeaa6 2/5: ; Make Eshell synchronous pipeline code more sim
From: |
Jim Porter |
Subject: |
master dd2438eeaa6 2/5: ; Make Eshell synchronous pipeline code more similar to asynchronous |
Date: |
Sun, 10 Sep 2023 13:42:08 -0400 (EDT) |
branch: master
commit dd2438eeaa6a2420383a5e783c7a2d178c64c590
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>
; Make Eshell synchronous pipeline code more similar to asynchronous
* lisp/eshell/esh-cmd.el (eshell-do-pipelines-synchronously): Use
'eshell-with-copied-handles'.
(eshell-execute-pipeline): Remove now-unnecessary let-bindings.
---
lisp/eshell/esh-cmd.el | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index f6846345d7d..45176b332d8 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -838,39 +838,37 @@ This is used on systems where async subprocesses are not
supported."
;; FIXME: is deferrable significant here?
(eshell--unmark-deferrable (car pipeline))
`(progn
+ (eshell-with-copied-handles
+ (progn
+ ,(when (cdr pipeline)
+ `(let ((output-marker ,(point-marker)))
+ (eshell-set-output-handle ,eshell-output-handle
+ 'append output-marker)))
+ (let (;; XXX: `eshell-in-pipeline-p' has a different meaning
+ ;; for synchronous processes: it's non-nil only when
+ ;; piping *to* a process.
+ (eshell-in-pipeline-p ,(and (cdr pipeline) t)))
+ (let ((result ,(car pipeline)))
+ ;; `tailproc' gets the result of the last successful
+ ;; process in the pipeline.
+ (set tailproc (or result (symbol-value tailproc))))))
+ ;; Steal handles if this is the last item in the pipeline.
+ ,(null (cdr pipeline)))
,(when (cdr pipeline)
- `(let ((output-marker ,(point-marker)))
- (eshell-set-output-handle ,eshell-output-handle
- 'append output-marker)))
- ;; 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))))
+ `(eshell-do-pipelines-synchronously (quote ,(cdr pipeline)))))))
(defalias 'eshell-process-identity 'identity)
(defmacro eshell-execute-pipeline (pipeline)
"Execute the commands in PIPELINE, connecting each to one another."
- `(let ((eshell-in-pipeline-p t)
- (headproc (make-symbol "headproc"))
+ `(let ((headproc (make-symbol "headproc"))
(tailproc (make-symbol "tailproc")))
(set headproc nil)
(set tailproc nil)
(progn
,(if eshell-supports-asynchronous-processes
`(eshell-do-pipelines ,pipeline)
- `(let ((tail-handles (eshell-duplicate-handles
- eshell-current-handles)))
- (eshell-do-pipelines-synchronously ,pipeline)))
+ `(eshell-do-pipelines-synchronously ,pipeline))
(eshell-process-identity (cons (symbol-value headproc)
(symbol-value tailproc))))))
- master updated (e7e7ce67d24 -> 2ec41c174f9), Jim Porter, 2023/09/10
- master 2ec41c174f9 5/5: Wait for all processes in a pipeline before resuming an Eshell command, Jim Porter, 2023/09/10
- master e554ee0b5f7 4/5: ; Move some Eshell tests to more-topical files, Jim Porter, 2023/09/10
- master f9667836c4b 3/5: Collect all processes in an Eshell pipeline, not just the head and tail, Jim Porter, 2023/09/10
- master dd2438eeaa6 2/5: ; Make Eshell synchronous pipeline code more similar to asynchronous,
Jim Porter <=
- master 6419f318e43 1/5: ; Move common Eshell pipeline code to a separate function, Jim Porter, 2023/09/10