bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53715: 29.0.50; [PATCH] Improve correctness of pipelines in Eshell


From: Jim Porter
Subject: bug#53715: 29.0.50; [PATCH] Improve correctness of pipelines in Eshell
Date: Tue, 1 Feb 2022 19:32:10 -0800

From `emacs -Q', start Eshell, and first run the following:

  ~ $ *echo hi | echo bye

This results in:

  bye
  ~ $ hi

That is, `*echo' writes its output *after* the prompt is emitted. This is because `eshell-do-pipelines' reports that there's no process object to wait for, so Eshell thinks the prompt can be emitted immediately. I fixed that in the first patch by setting the `tailproc' in a different spot. With this change, the result is:

  bye
  hi
  ~ $

This may be a bit surprising, since you'd normally expect "echo bye" to read "hi" on its stdin and just ignore it. However, the builtin Eshell echo command doesn't consume stdin, so it just goes straight to stdout instead. It's in reverse order because Eshell runs the pipeline from right-to-left in order to hook up the pipes properly. For how the builtin Eshell echo works, I think this is the right behavior. (If people disagree, I can fix this, but not right now; I'm working on a patch series to properly support piping to Lisp functions in Eshell, and I can change it - or not - once that's done.)

Second, run this:

  ~ $ tr a-z A-Z | rev
  hello RET
  C-c C-d  ;; Send EOF

The result is:

  olleh  ;; should be "OLLEH"

This happens because Eshell only keeps track of the tail process when running an external process, so when sending stdin, it gets sent to the tail process (`rev'), not the head (`tr'). I fixed this in the second patch by recording both the head and tail processes and updating the various places that use the current process to use the right one.

Attachment: 0001-Ensure-that-tailproc-is-set-for-the-last-process-in-.patch
Description: Text document

Attachment: 0002-When-executing-an-Eshell-pipeline-send-input-to-the-.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]