]> git.eshelyaron.com Git - emacs.git/commitdiff
Ensure that the CAR of 'eshell-last-async-procs' always points to a process
authorJim Porter <jporterbugs@gmail.com>
Sat, 5 Feb 2022 06:41:39 +0000 (22:41 -0800)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 5 Feb 2022 06:58:59 +0000 (07:58 +0100)
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
test/lisp/eshell/eshell-tests.el

index e702de03a0326f4e2738e115c53fa1efe93c81fb..5819506cc0e14c65342edbfae067b38b585a3f4b 100644 (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))))))
 
index c5ca0a548520a78451d1b03d5680df52321cde5f..d6ee1bdb17589639c3ec6c141a317c171bae47ce 100644 (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"))