emacs-orgmode
[Top][All Lists]
Advanced

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

Re: babel output seems to drop anything before % (in session)


From: Felix Freeman
Subject: Re: babel output seems to drop anything before % (in session)
Date: Tue, 07 Jun 2022 17:50:01 -0400

I've been able to bypass the error by adding the following to my .emacs

(require 'ob-shell)

(defun org-babel-sh-strip-weird-long-prompt (string)
  "Remove prompt cruft from a string of shell output."
  (while (string-match shell-prompt-pattern string)
    (setq string (substring string (match-end 0))))
  string)

(setq shell-prompt-pattern "^sh-[[:digit:]].[[:digit:]]\$ ")

Of course, this is is just a dirty hack not suitable for a release.

It seems logical that `org-babel-sh-strip-weird-long-prompt` on
`ob-shell.el` respects `shell-prompt-pattern` from `shell.el`. It's not
like this on the released source code.

But to be honest still the idea ripping a dynamic string from the shell
output seems pretty hackish to me. I'm not really aware of the internals
of `comint.el`, but I think that instead it should set the shell $PS1 to
an empty value and read the thing afterwards, or - if this changes
things too much - at least set $PS1 to a very unique and distinctive
value in order to avoid these kind of bugs.

Felix Freeman



reply via email to

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