emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alice Liquori <aliquori@sig-gis.com>
To: emacs-orgmode@gnu.org
Subject: Bash blocks with :session pollute results with 'org_babel_sh_prompt>'
Date: Thu, 17 Nov 2022 12:23:32 -0500	[thread overview]
Message-ID: <CADnjhKO9ip6ssujZKj82FQSfi79GZbNZCYO=LN5X_6CONS65PA@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2022-11-18  3:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 17:23 Alice Liquori [this message]
2022-11-18  8:47 ` Bash blocks with :session pollute results with 'org_babel_sh_prompt>' Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADnjhKO9ip6ssujZKj82FQSfi79GZbNZCYO=LN5X_6CONS65PA@mail.gmail.com' \
    --to=aliquori@sig-gis.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).