emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Loris Bennett" <loris.bennett@fu-berlin.de>
To: Grant Rettke <gcr@wisdomandwonder.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: babel: fancy prompt messes up results of shell block
Date: Fri, 18 Sep 2015 14:16:45 +0200	[thread overview]
Message-ID: <87twqrhqhe.fsf@hornfels.zedat.fu-berlin.de> (raw)
In-Reply-To: <CAAjq1mcAdi0FAiC5W0iKgsEAXGZ4qpZi0LZJ=HCSmsnqJeSDbA@mail.gmail.com> (Grant Rettke's message of "Fri, 11 Sep 2015 12:59:40 -0500")

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.

      reply	other threads:[~2015-09-18 12:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87twqrhqhe.fsf@hornfels.zedat.fu-berlin.de \
    --to=loris.bennett@fu-berlin.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=gcr@wisdomandwonder.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).