So I have a patch written that doesn't completely fix the problem, but maybe makes enough progress that someone else can figure it out. The issue is that comint-prompt-regexp is reading the "% " as a prompt, and taking everyone off before it. I've added another parameter to org-babel-comint-with-output in the "meta" to pass our own regexp to replace comint-prompt-regexp, which works except when it doesn't. The regexp I've added is just "\n" now, so the newline characters are removed. The tests that Daniele added as a patch don't quite pass though with this. The issue is that something in the way the output is posted in the output buffer includes the prompt occasionally is included in a line and occasionally not. It seems the first time the block of code is executed, it is included (and therefore needs to be removed) and each other time it is not, so it is only the first time that it is run is not working properly. This is obviously way too fragile to actually merge, but I was hoping the work I've done so far is enough to help someone else make progress. I'll probably take another stab at this tomorrow (since it's bugging me), but thought I'd share what I have for now. Cheers, Nick On 5/6/21 8:24 AM, Ihor Radchenko wrote: > "Nicholas Savage" writes: > >> I can confirm this too on the latest master. >> >> I took a quick peek this morning, and my suspicion is that the problem is somewhere within org-babel-comint-with-output in lisp/ob-comint.el, but I'm not positive at this point. > I confirm as well. I also saw an anomaly in the comint buffer. Note that > all the output lines, except "five 0% six" are after the shell prompt. > As I remember, the code expects the result to be exactly at the prompt > line. So, for some reason the first command ("echo five 0% six") of the > second block does not get inserted at the empty line. > > echo one 0% two > yantar92@yantar92-laptop ~/.data/1e/90360c-ef36-4d20-8706-990ae2530cbf $ one 0% two > echo tree 0% four > yantar92@yantar92-laptop ~/.data/1e/90360c-ef36-4d20-8706-990ae2530cbf $ tree 0% four > echo 'org_babel_sh_eoe' > yantar92@yantar92-laptop ~/.data/1e/90360c-ef36-4d20-8706-990ae2530cbf $ org_babel_sh_eoe > yantar92@yantar92-laptop ~/.data/1e/90360c-ef36-4d20-8706-990ae2530cbf $ echo five 0% six > five 0% six > echo seven 0% eight > yantar92@yantar92-laptop ~/.data/1e/90360c-ef36-4d20-8706-990ae2530cbf $ seven 0% eight > echo 'org_babel_sh_eoe' > yantar92@yantar92-laptop ~/.data/1e/90360c-ef36-4d20-8706-990ae2530cbf $ org_babel_sh_eoe > yantar92@yantar92-laptop ~/.data/1e/90360c-ef36-4d20-8706-990ae2530cbf $ > > Best, > Ihor