Org-mode sh block showing shell prompt in the results when using :session

Viewed 135

I am experiencing an issue in org-mode, where shell source blocks are including the shell prompt in the results when i use :session in the header.

This seems to happen whenever there is either an empty line or a line starting with a comment in the code.

I already tried to unset the PS1 variable or to set it to an empty string (""), but code block's execution hangs with any of these.

EXAMPLES:

When not using :session, the results display correctly:

#+begin_src sh :results output replace :exports both
echo "TEST1"
#COMMENT
echo "TEST2"

echo "TEST3"
#COMMENT

echo "TEST4"
#COMMENT

#+end_src
#+RESULTS:
: TEST1
: TEST2
: TEST3
: TEST4

When using :session, the results will include the shell prompt once for every empty line or line that starts with a comment. See bellow:

#+begin_src sh :results output replace :exports both :session test
echo "TEST1"
#COMMENT
echo "TEST2"

echo "TEST3"
#COMMENT

echo "TEST4"
#COMMENT

#+end_src
#+RESULTS:
: TEST1
: sh-5.0$ TEST2
: sh-5.0$ TEST3
: sh-5.0$ sh-5.0$ TEST4

And here is the output of the 'test' buffer when using :session :

sh-5.0$ echo "TEST1"
TEST1
sh-5.0$ #COMMENT
sh-5.0$ echo "TEST2"
TEST2
sh-5.0$ 
sh-5.0$ echo "TEST3"
TEST3
sh-5.0$ #COMMENT
sh-5.0$ 
sh-5.0$ echo "TEST4"
TEST4
sh-5.0$ #COMMENT
sh-5.0$ echo 'org_babel_sh_eoe'
org_babel_sh_eoe
sh-5.0$ 
0 Answers
Related