From: Jim Porter Date: Sat, 5 Feb 2022 06:41:39 +0000 (-0800) Subject: Ensure that the CAR of 'eshell-last-async-procs' always points to a process X-Git-Tag: emacs-29.0.90~2514 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=785a045b868e0aeef08858e86a9efe48311e8f48;p=emacs.git 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. --- diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index e702de03a03..5819506cc0e 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -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)))))) diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index c5ca0a54852..d6ee1bdb175 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el @@ -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"))