From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Loris Bennett" Subject: Re: babel: fancy prompt messes up results of shell block Date: Fri, 18 Sep 2015 14:16:45 +0200 Message-ID: <87twqrhqhe.fsf@hornfels.zedat.fu-berlin.de> References: <87k2rxbbqd.fsf@hornfels.zedat.fu-berlin.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcuaz-0006Al-B1 for emacs-orgmode@gnu.org; Fri, 18 Sep 2015 08:16:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcuav-0006sB-Ai for emacs-orgmode@gnu.org; Fri, 18 Sep 2015 08:16:53 -0400 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]:54905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcuau-0006pm-Ts for emacs-orgmode@gnu.org; Fri, 18 Sep 2015 08:16:49 -0400 In-Reply-To: (Grant Rettke's message of "Fri, 11 Sep 2015 12:59:40 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Grant Rettke Cc: "emacs-orgmode@gnu.org" 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.