Matt <m...@excalamus.com> writes: > It's not clear to me what causes the observed behavior. > > Assigning '1' and '2' to the echoes in each block shows that the results for > the second block are placed in the first: > ...
What happens is related to the way ob-shell insert async indicators at the beginning/end of the code block. The begin indicator is inserted synchronously, while the end indicator is inserted _after_ the code block is evaluated. In the bug report, what happens is the following: 1. We call the first src bloc, async "begin" indicator is inserted into the comint buffer immediately. The rest of the code is still running 2. We call the second src block, another "begin" indicator is inserted ... 3. _First_ src block finishes, inserting "end" indicator _after_ the rest of the code, capturing both outputs 4. _Second_ src block finishes This is what I see in the comint buffer sh-5.2$ PROMPT_COMMAND=;PS1="𒆸 ";PS2= 𒆸 echo 'ob_comint_async_shell_start_2ecc6791-9a1a-4118-b6ea-434e8ea15b8b' exec 2>&1 sleep 5 echo "almost done1" sleep 3 echo "done1" : echo 'ob_comint_async_shell_end_2ecc6791-9a1a-4118-b6ea-434e8ea15b8b' ob_comint_async_shell_start_2ecc6791-9a1a-4118-b6ea-434e8ea15b8b 𒆸 𒆸 echo 'ob_comint_async_shell_start_b3810f61-ab61-4895-b0a5-e75133f03a47' exec 2>&1 sleep 1 echo "almost done2" sleep 6 echo "done2" : echo 'ob_comint_async_shell_end_b3810f61-ab61-4895-b0a5-e75133f03a47' 𒆸 almost done1 𒆸 𒆸 done1 𒆸 𒆸 ob_comint_async_shell_end_2ecc6791-9a1a-4118-b6ea-434e8ea15b8b 𒆸 ob_comint_async_shell_start_b3810f61-ab61-4895-b0a5-e75133f03a47 𒆸 𒆸 𒆸 almost done2 𒆸 𒆸 done2 𒆸 𒆸 ob_comint_async_shell_end_b3810f61-ab61-4895-b0a5-e75133f03a47 𒆸 -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>