emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash blocks with :session pollute results with 'org_babel_sh_prompt>'


From: Alice Liquori
Subject: Bash blocks with :session pollute results with 'org_babel_sh_prompt>'
Date: Thu, 17 Nov 2022 12:23:32 -0500

I ran into an issue with bash blocks that use a session where 'org_babel_sh_prompt> ' is strewn throughout the output. For large blocks the intended output can be completely buried. Here is an example.

#+begin_src bash :session test :results output
echo "hello"
#+end_src

#+RESULTS:
: org_babel_sh_prompt> org_babel_sh_prompt> org_babel_sh_prompt> org_babel_sh_prompt> hello

This is caused by a leading carat in the `comint-prompt-regexp` regex in `org-babel-sh-initiate-session` in `ob-shell.el`, and the fix is incredibly simple.

Here is the diff that I've generated.

--- ob-shell-old.el 2022-11-15 14:29:34.351598206 -0500
+++ ob-shell-new.el 2022-11-15 14:31:28.416924869 -0500
@@ -255,8 +255,7 @@
              (current-buffer)
              (format org-babel-prompt-command org-babel-sh-prompt))
             (setq-local comint-prompt-regexp
-                        (concat "^" (regexp-quote org-babel-sh-prompt)
-                                " *"))
+                        (concat (regexp-quote org-babel-sh-prompt) " *"))
     ;; Needed for Emacs 23 since the marker is initially
     ;; undefined and the filter functions try to use it without
     ;; checking.

This is my first OSS contribution, I initially reported this to the main emacs bug report email using their guidelines. If I need to alter this in any way, let me know and I am willing to make changes.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]