Grant Rettke writes:
> On Fri, Sep 11, 2015 at 3:29 AM, Loris Bennett
> wrote:
>> Hi,
>>
>> I have a bit of a fancy bash prompt and so the output of evaluating a
>> block of shell script ends up a little messy:
>>
>> #+BEGIN_SRC sh :session install :results output
>> echo blah
>> #+END_SRC
>>
>> #+RESULTS:
>> : blah
>> : ]2;loris@soroban [35m[10:21:45] [31mloris@soroban [36m(1058)
>> [33m/home/loris/tmp[34m[0m
>>
>> Is there any way to avoid this short of resetting PS1 within the babel
>> session?
>
> It looks like `org-babel-sh-strip-weird-long-prompt' removed the
> prompt from the output. Your prompt doesn't match that regex? Maybe
> redefine it there.
So this is what you are talking about:
(defun org-babel-sh-strip-weird-long-prompt (string)
"Remove prompt cruft from a string of shell output."
(while (string-match "^% +[\r\n$]+ *" string)
(setq string (substring string (match-end 0
string)
Bearing in mind that my pattern-matching experience is mainly from Perl,
I don't get the regex above. Isn't it just going to match a prompt
starting with a '%' followed by a bunch of spaces, carriage returns /
newlines, and more spaces? That may be both weird and potentially long,
but isn't it quite a specific subset of weird, long prompts?
Cheers,
Loris
--
This signature is currently under construction.