Steps to reproduce: emacs -Q M-x eshell-command RET oops C-g M-x eshell This will show the most-recent command in the Eshell history as "oops". That's because it was adding to the history in 'minibuffer-exit-hook', which runs regardless of *how* you exit the minibuffer. This regressed from 093a360251, and I misunderstood the conditions where 'minibuffer-exit-hook' runs. Attached is a patch to fix this. Is this ok for the release branch?