diff options
author | Jim Porter <jporterbugs@gmail.com> | 2022-05-22 17:27:48 -0700 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-05-24 14:58:00 +0200 |
commit | a49ecdd0ff2b2526fcc519bb23ce1f5113c8fb1d (patch) | |
tree | d8ac3f279ad977d2ae21f42d27a389b6b53ecddd /lisp/eshell/esh-cmd.el | |
parent | be17333acee2086d1c729197dfe64432f6ad6625 (diff) | |
download | emacs-a49ecdd0ff2b2526fcc519bb23ce1f5113c8fb1d.tar.gz emacs-a49ecdd0ff2b2526fcc519bb23ce1f5113c8fb1d.tar.bz2 emacs-a49ecdd0ff2b2526fcc519bb23ce1f5113c8fb1d.zip |
Keep subcommands in pipelines from clobbering the head/tail processes
* lisp/eshell/esh-cmd.el (eshell-execute-pipeline): Use 'make-symbol'
for headproc and tailproc.
(eshell-do-pipelines, eshell-do-pipelines-synchronously): Adapt to the
above.
* test/lisp/eshell/eshell-tests.el (eshell-test/pipe-subcommand)
(eshell-test/pipe-subcommand-with-pipe): New test.
* doc/misc/eshell.texi (Bugs and ideas): Remove item about piping to
process from loop; this commit fixes it (bug#55590).
Diffstat (limited to 'lisp/eshell/esh-cmd.el')
-rw-r--r-- | lisp/eshell/esh-cmd.el | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 42616e7037d..73c250632ce 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -827,8 +827,8 @@ This macro calls itself recursively, with NOTFIRST non-nil." ((cdr pipeline) t) (t (quote 'last))))) (let ((proc ,(car pipeline))) - (setq headproc (or proc headproc)) - (setq tailproc (or tailproc proc)) + (set headproc (or proc (symbol-value headproc))) + (set tailproc (or (symbol-value tailproc) proc)) proc)))))) (defmacro eshell-do-pipelines-synchronously (pipeline) @@ -861,7 +861,7 @@ This is used on systems where async subprocesses are not supported." (let ((result ,(car pipeline))) ;; tailproc gets the result of the last successful process in ;; the pipeline. - (setq tailproc (or result tailproc)) + (set tailproc (or result (symbol-value tailproc))) ,(if (cdr pipeline) `(eshell-do-pipelines-synchronously (quote ,(cdr pipeline)))) result)))) @@ -870,7 +870,11 @@ This is used on systems where async subprocesses are not supported." (defmacro eshell-execute-pipeline (pipeline) "Execute the commands in PIPELINE, connecting each to one another." - `(let ((eshell-in-pipeline-p t) headproc tailproc) + `(let ((eshell-in-pipeline-p t) + (headproc (make-symbol "headproc")) + (tailproc (make-symbol "tailproc"))) + (set headproc nil) + (set tailproc nil) (progn ,(if (fboundp 'make-process) `(eshell-do-pipelines ,pipeline) @@ -880,7 +884,8 @@ This is used on systems where async subprocesses are not supported." (car (aref eshell-current-handles ,eshell-error-handle)) nil))) (eshell-do-pipelines-synchronously ,pipeline))) - (eshell-process-identity (cons headproc tailproc))))) + (eshell-process-identity (cons (symbol-value headproc) + (symbol-value tailproc)))))) (defmacro eshell-as-subcommand (command) "Execute COMMAND using a temp buffer. |