Subject: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell

From: Jim Porter <[email-masked]>
Date: Fri, 1 Sep 2023 22:17:30 -0700

On 8/31/2023 2:31 AM, Davide Masserut via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
>> (FWIW, I personally don't like the idea of showing this on the mode
>> line: the mode line is already quite cramped
> 
> I agree with you, this is one of the main reasons I had in mind when I 
> made the first patch.

Hmm, well if everyone else disagrees, I suppose I don't see any *major* 
issues with including the exit status in the prompt, though I'm a little 
worried it would annoy people who like the current way. If it were 
easier to customize the prompt, I don't think I'd be as worried. Fixing 
that for real is probably beyond the scope of this bug, but I do have a 
WIP patch for it.

If we do use the mode-line to display this though, I was initially 
thinking we could use the existing variable 
'eshell-command-running-string', which we could set to something like 
"!!" in 'eshell-command-finished'. That's not as useful as the actual 
number though, and honestly I'm not sure the current 
'eshell-status-in-mode-line' code is a good idea anyway. It 
(buffer-locally) replaces the mode-line construct immediately after 
'mode-line-front-space', which means you lose some of the 
potentially-useful information there.

Maybe it would make sense to move *all* of the current Eshell mode-line 
stuff to the 'mode-line-process' construct. That seems like it would be 
less brittle. That is, in 'mode-line-process', we could show whether a 
command is running or the exit status if nothing's running (possibly 
including successful exit). What does everyone think about that?

>> and OTOH Bash does show abnormal exit codes as part of its prompt.  
>> But feel free to disregard
>> my opinions, as I'm not a heavy user of Eshell.)
> 
> fish and some zsh distributions also show the error in the prompt.

Do they? I tried to see what the default was for Bash and after some 
searching, it seemed that it doesn't show the exit status by default. 
But that could be wrong.

In any case, sorry for the back and forth. This is another corner of 
Eshell I wasn't really aware of until this bug, so I'm not 100% sure 
what implementation follows the spirit of Eshell the most...