diff options
| author | Jim Porter | 2022-01-27 23:13:36 -0800 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-02-03 20:02:20 +0100 |
| commit | 2e60ef696a3cf16b0eb297948e27ba0cb32a125e (patch) | |
| tree | bec32b4c1c5b76e65272d22c4c1e49312e0aae79 | |
| parent | dcc97fec29785051d7d11a66beb5f44fbaae6289 (diff) | |
| download | emacs-2e60ef696a3cf16b0eb297948e27ba0cb32a125e.tar.gz emacs-2e60ef696a3cf16b0eb297948e27ba0cb32a125e.zip | |
Ensure that tailproc is set for the last process in an Eshell pipeline
In particular, this used to fail for pipelines where the last process
in the pipeline came from the first element of the pipeline. This
could happen when a process was piped to an ordinary Lisp function,
like in '*echo hi | echo bye'.
* lisp/eshell/esh-cmd.el (eshell-do-pipelines): Set the tailproc even
for the first process in the pipeline.
* test/lisp/eshell/eshell-tests.el (eshell-test/pipe-tailproc): New
test.
| -rw-r--r-- | lisp/eshell/esh-cmd.el | 7 | ||||
| -rw-r--r-- | test/lisp/eshell/eshell-tests.el | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 04d65df4f33..14139896dd4 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el | |||
| @@ -764,8 +764,7 @@ This macro calls itself recursively, with NOTFIRST non-nil." | |||
| 764 | (eshell-set-output-handle ,eshell-output-handle | 764 | (eshell-set-output-handle ,eshell-output-handle |
| 765 | 'append nextproc) | 765 | 'append nextproc) |
| 766 | (eshell-set-output-handle ,eshell-error-handle | 766 | (eshell-set-output-handle ,eshell-error-handle |
| 767 | 'append nextproc) | 767 | 'append nextproc))) |
| 768 | (setq tailproc (or tailproc nextproc)))) | ||
| 769 | ,(let ((head (car pipeline))) | 768 | ,(let ((head (car pipeline))) |
| 770 | (if (memq (car head) '(let progn)) | 769 | (if (memq (car head) '(let progn)) |
| 771 | (setq head (car (last head)))) | 770 | (setq head (car (last head)))) |
| @@ -781,7 +780,9 @@ This macro calls itself recursively, with NOTFIRST non-nil." | |||
| 781 | ,(cond ((not notfirst) (quote 'first)) | 780 | ,(cond ((not notfirst) (quote 'first)) |
| 782 | ((cdr pipeline) t) | 781 | ((cdr pipeline) t) |
| 783 | (t (quote 'last))))) | 782 | (t (quote 'last))))) |
| 784 | ,(car pipeline)))))) | 783 | (let ((proc ,(car pipeline))) |
| 784 | (setq tailproc (or tailproc proc)) | ||
| 785 | proc)))))) | ||
| 785 | 786 | ||
| 786 | (defmacro eshell-do-pipelines-synchronously (pipeline) | 787 | (defmacro eshell-do-pipelines-synchronously (pipeline) |
| 787 | "Execute the commands in PIPELINE in sequence synchronously. | 788 | "Execute the commands in PIPELINE in sequence synchronously. |
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index 542815df809..7658d5f5517 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el | |||
| @@ -129,6 +129,13 @@ e.g. \"{(+ 1 2)} 3\" => 3" | |||
| 129 | (eshell-command-result-p "echo ${echo hi}-${*echo there}" | 129 | (eshell-command-result-p "echo ${echo hi}-${*echo there}" |
| 130 | "hi-there\n"))) | 130 | "hi-there\n"))) |
| 131 | 131 | ||
| 132 | (ert-deftest eshell-test/pipe-tailproc () | ||
| 133 | "Check that piping a process to a non-process command waits for the process" | ||
| 134 | (skip-unless (executable-find "echo")) | ||
| 135 | (with-temp-eshell | ||
| 136 | (eshell-command-result-p "*echo hi | echo bye" | ||
| 137 | "bye\nhi\n"))) | ||
| 138 | |||
| 132 | (ert-deftest eshell-test/window-height () | 139 | (ert-deftest eshell-test/window-height () |
| 133 | "$LINES should equal (window-height)" | 140 | "$LINES should equal (window-height)" |
| 134 | (should (eshell-test-command-result "= $LINES (window-height)"))) | 141 | (should (eshell-test-command-result "= $LINES (window-height)"))) |