On 11/24/2022 7:49 AM, Milan Zimmermann wrote: > Emacs 29 Eshell Bug: Sourcing 'redirect-echo.esh' and redirecting output > to a file, results in the first echo string ('hello') showing in eshell, > only the second ('there')(presumably because it is last) showing in the > output file. It turns out there's an even simpler way to reproduce this: ~ $ {echo hi; echo bye} > # hi ;; Buffer "buf" now contains the string "bye". Initially[1], I said that this was an issue with the implementation of 'eshell-protect', but it turns out that it's actually an issue in an adjacent part of the Eshell I/O code. Specifically, every statement in Eshell gets its own set of default I/O handles, when it should actually inherit the handles from its parent. So in the example above, "echo hi" has the default I/O handles (pointing to the terminal), when its stdout handle should point to the buffer "buf". Attached is a patch series to fix this, with a bunch of new tests. I also fixed a related issue where redirecting to /dev/null could clobber your other redirects. (There's *also* an issue that should be fixed for the release branch; I'll send that in a separate message.) [1] https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg01504.html