[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] babel: fancy prompt messes up results of shell block
From: |
Loris Bennett |
Subject: |
Re: [O] babel: fancy prompt messes up results of shell block |
Date: |
Fri, 18 Sep 2015 14:16:45 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Grant Rettke <address@hidden> writes:
> On Fri, Sep 11, 2015 at 3:29 AM, Loris Bennett
> <address@hidden> 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;address@hidden [35m[10:21:45] address@hidden [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.