From 785a045b868e0aeef08858e86a9efe48311e8f48 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Fri, 4 Feb 2022 22:41:39 -0800 Subject: [PATCH] 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. --- lisp/eshell/esh-cmd.el | 3 +-- test/lisp/eshell/eshell-tests.el | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) 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")) -- 2.39.5