(Restoring the original subject so this issue is hopefully easier to track.) On 1/24/2023 5:39 PM, Jim Porter wrote: > The fix here is that when we're inside a 'let' and see 'eshell-defer' > get thrown, update the let-bindings in place. So now the updated form > would look like: > >   (let ((process-environment (cons "var=value" process-environment))) >     '"value"   ; Not really necessary, but it doesn't hurt anything. >     (eshell-external-command "grep") >     (eshell/echo (getenv "var"))) > > And so with this, it all works. Here's an updated patch with an improved comment introducing Eshell's iterative evaluation. Hopefully the added detail will help anyone else who looks into this code (assuming I haven't replaced it with threads or generator.el's CPS machinery by then, of course!). Note: I have a few other patches to apply after this that should let 'eshell-do-eval' handle "normal" Emacs Lisp for the most part. This will make it easier to maintain all the code that generates Eshell's internal forms, as well as simplifying the migration to threads and/or generator.el. I'll file those separately though, since this is tricky code, and I want to be sure each change gets a reasonable amount of attention.