Structured commands are just Eshell flow control commands, like 'if' and 'while'. These expected you to set 'eshell-test-body' and 'eshell-command-body' when implementing them, and were very hard to get right (see bug#12571 for example). Instead, let's improve Eshell's iterative command evaluation some more so that you can write the implementations for these commands like normal. I think this is beneficial for two main reasons: a) it should get us closer to replacing Eshell's iterative evaluation with the CPS machinery in generator.el (bug#37635)[1], and b) third-parties should have an easier time writing their own fancy Eshell commands using the command-rewriting hooks. Given that we have fairly thorough regression tests in Eshell now, I'm pretty confident that these patches don't break anything. [1] I think I mentioned it elsewhere, but I'm hoping to make sure that when we do switch to the CPS machinery (or maybe to threads), it's just a drop-in replacement. That way, if there are problems, it should be easy to revert to the classic iterative evaluation code. Maybe we could even provide a defcustom for it just in case.