Ensure that the CAR of 'eshell-last-async-procs' always points to a process

Previously, if a non-process was piped to a process, this could end up
being nil, which isn't correct.  'eshell-last-async-procs' should just
ignore non-process commands in a pipeline.

* lisp/eshell/esh-cmd.el (eshell-do-pipelines): Set 'headproc'
correctly.

* test/lisp/eshell/eshell-tests.el (eshell-test/pipe-headproc): New test.
This commit is contained in:
Jim Porter 2022-02-04 22:41:39 -08:00 committed by Lars Ingebrigtsen
parent a8de2e20e0
commit 785a045b86
2 changed files with 8 additions and 2 deletions

View file

@ -800,8 +800,7 @@ This macro calls itself recursively, with NOTFIRST non-nil."
((cdr pipeline) t)
(t (quote 'last)))))
(let ((proc ,(car pipeline)))
,(unless notfirst
'(setq headproc proc))
(setq headproc (or proc headproc))
(setq tailproc (or tailproc proc))
proc))))))

View file

@ -123,6 +123,13 @@ e.g. \"{(+ 1 2)} 3\" => 3"
(eshell-command-result-p "echo ${echo hi}-${*echo there}"
"hi-there\n")))
(ert-deftest eshell-test/pipe-headproc ()
"Check that piping a non-process to a process command waits for the process"
(skip-unless (executable-find "cat"))
(with-temp-eshell
(eshell-command-result-p "echo hi | *cat"
"hi")))
(ert-deftest eshell-test/pipe-tailproc ()
"Check that piping a process to a non-process command waits for the process"
(skip-unless (executable-find "echo"))