On 8/6/2023 12:20 PM, Jim Porter wrote: > The I/O refcounting code in Eshell is pretty tricky. I have a WIP patch > that will hopefully make it less error-prone, but I'll worry about that > later... Happily, this issue *wasn't* a bug in the I/O refcounting code. The failed assertion (which is new in Emacs 30 and exists for exactly this reason) just revealed a bug in another part of Eshell. Fix attached (plus fixing another issue mentioned in the code comments) with some regression tests. Let me know if this works for you, or if you see any further issues.