Eli Zaretskii writes: Hi Eli, >> In order to understand the situation better, I have enhanced my test >> code to cover all different values of shell-command-dont-erase-buffer, >> and whether the OUTPUT-BUFFER argument of shell-command is the current >> buffer, or not. Here's the code: > > AFAIU, the use case of OUTPUT-BUFFER being different from the current > buffer is meant for the case where subsequent commands accumulate the > output in that buffer, which is why the output is appended in that > case. > > Does what you see make more sense now? Almost. But it is not documented. Maybe we shall apply the appended patch. And if shell-command-dont-erase-buffer is end-last-out with output buffer not being the current one, the behavior is simply wrong, see my previous analysis. At least *this* case must be fixed. Best regards, Michael.