emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bash blocks with :session pollute results with 'org_babel_sh_prompt>'
@ 2022-11-17 17:23 Alice Liquori
  2022-11-18  8:47 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Alice Liquori @ 2022-11-17 17:23 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 1718 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bash blocks with :session pollute results with 'org_babel_sh_prompt>'
  2022-11-17 17:23 Bash blocks with :session pollute results with 'org_babel_sh_prompt>' Alice Liquori
@ 2022-11-18  8:47 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-11-18  8:47 UTC (permalink / raw)
  To: Alice Liquori; +Cc: emacs-orgmode

Alice Liquori <aliquori@sig-gis.com> writes:

> 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

Thanks for reporting!

Please, update Org. This has been fixed on the latest main.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-18  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 17:23 Bash blocks with :session pollute results with 'org_babel_sh_prompt>' Alice Liquori
2022-11-18  8:47 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).