* babel: fancy prompt messes up results of shell block
@ 2015-09-11 8:29 Loris Bennett
2015-09-11 17:59 ` Grant Rettke
0 siblings, 1 reply; 3+ messages in thread
From: Loris Bennett @ 2015-09-11 8:29 UTC (permalink / raw)
To: emacs-orgmode
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\a[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?
Cheers,
Loris
--
This signature is currently under construction.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: babel: fancy prompt messes up results of shell block
2015-09-11 8:29 babel: fancy prompt messes up results of shell block Loris Bennett
@ 2015-09-11 17:59 ` Grant Rettke
2015-09-18 12:16 ` Loris Bennett
0 siblings, 1 reply; 3+ messages in thread
From: Grant Rettke @ 2015-09-11 17:59 UTC (permalink / raw)
To: Loris Bennett; +Cc: emacs-orgmode@gnu.org
On Fri, Sep 11, 2015 at 3:29 AM, Loris Bennett
<loris.bennett@fu-berlin.de> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: babel: fancy prompt messes up results of shell block
2015-09-11 17:59 ` Grant Rettke
@ 2015-09-18 12:16 ` Loris Bennett
0 siblings, 0 replies; 3+ messages in thread
From: Loris Bennett @ 2015-09-18 12:16 UTC (permalink / raw)
To: Grant Rettke; +Cc: emacs-orgmode@gnu.org
Grant Rettke <gcr@wisdomandwonder.com> writes:
> On Fri, Sep 11, 2015 at 3:29 AM, Loris Bennett
> <loris.bennett@fu-berlin.de> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-18 12:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-11 8:29 babel: fancy prompt messes up results of shell block Loris Bennett
2015-09-11 17:59 ` Grant Rettke
2015-09-18 12:16 ` Loris Bennett
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).