Whoops, one of the intermediate changes I'd made while working on these patches broke a bunch of the regression tests, so here's the fixed version. I also renamed a few of the new variables to be clearer that they're for internal use only. Since it sounds like all the other concerns have been addressed, I'll probably merge this in the next day or so. (This is the last non-bugfix change I'd like to land for Eshell in Emacs 30.)