[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] Prompt appears in async shell results
From: |
Ihor Radchenko |
Subject: |
Re: [BUG] Prompt appears in async shell results |
Date: |
Mon, 05 Feb 2024 14:02:55 +0000 |
Matt <matt@excalamus.com> writes:
> #+begin_src emacs-lisp
> (org-babel-do-load-languages 'org-babel-load-languages '((shell . t)))
> #+end_src
>
> #+begin_src sh :results output :session *test* :async t
> cd /tmp
> echo "hello world"
> #+end_src
>
> #+RESULTS:
> : org_babel_sh_prompt> hello world
Confirmed.
> ** Thoughts
> A quick fix is:
>
> #+begin_src diff
> modified lisp/ob-shell.el
> @@ -289,7 +289,7 @@ See `org-babel-comint-async-indicator'.")
> (defun ob-shell-async-chunk-callback (string)
> "Filter applied to results before insertion.
> See `org-babel-comint-async-chunk-callback'."
> - (replace-regexp-in-string comint-prompt-regexp "" string))
> + (replace-regexp-in-string org-babel-sh-prompt "" string))
> ...
> I'm not sure this is the best way.
It is not. It works by accident.
Other edge cases may appear with chunks containing parts of the prompt.
> It seems to me that we should extract the filter from
> =org-babel-comint-with-output= and use it in both
> =org-babel-comint-with-output= and =org-babel-comint-async-filter=.
Yes. The right fix would be extracting the filter from
`org-babel-comint-with-output' and re-using it.
--
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>