From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4MxJJ/EU+F/LewAA0tVLHw (envelope-from ) for ; Fri, 08 Jan 2021 08:16:49 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id EMgiI/EU+F9xIQAA1q6Kng (envelope-from ) for ; Fri, 08 Jan 2021 08:16:49 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0D200940416 for ; Fri, 8 Jan 2021 08:16:49 +0000 (UTC) Received: from localhost ([::1]:34600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxmwx-000169-TQ for larch@yhetil.org; Fri, 08 Jan 2021 03:16:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxmwU-00015x-0g for emacs-orgmode@gnu.org; Fri, 08 Jan 2021 03:16:19 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:41638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxmwN-00024U-AN for emacs-orgmode@gnu.org; Fri, 08 Jan 2021 03:16:17 -0500 Received: by mail-wr1-x42b.google.com with SMTP id a12so8073557wrv.8 for ; Fri, 08 Jan 2021 00:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=eZf1SQLYNFpIsBE0R+Nru+mZZs9FMDFbZff/QPy/Ajc=; b=mdDF8+EcS3jHtiEM++AF1tAQ54uk0Q7O6pPCtyFR3mPzdfIx5qimYstMKOsT1nogJ9 +UGwXpnZgZSFoJaUOVZHLcL0wngSvQTtIdTUMO5bxejIs1mtyYTpu1fGWr7zAOBv+aSw HytLD0U7KJ4hYuZmD7UOw2MwhXCCxu5l6p1NU9zVmoefkFHuiKyxeIKuvlJDuBkSH7+r fzlBGYbUkM2Fy4LucTG5zRGvQQZuWvxzkJ24aReLHeePlW3zohPGjkHyBWwu6hkp60ve t0c+Y634TajQcUnBkclocQhJFclKmK6KTMspBQSlVTnBCGx9FsJR4gmMCTDgv7bZ3NUi otRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=eZf1SQLYNFpIsBE0R+Nru+mZZs9FMDFbZff/QPy/Ajc=; b=B0yRHvdZecygkiYZ+IEULUkyV92C7pqZhcD+xeO12SkpD/oOVlZK16hpvqsL6bGh6F cwYhNDEKjPRauJh6YBwy0Kv6/KX+MNyb7CAKf7wPAQLt09kn1a0hTlK5PwjCeU+ppjUW scrWAp66r0ccKznAH49V23gFuNnt4aD4s8XemH9oJOblAsIPNWsKrP3/JsHlEMNnwRXG E1Sq8IZRjdxI4yMdUiauWfI05et0EMMspEKTK7FnwFRwOEjrtnRIlv/IkJqRUB/7gCrP dT1hXugXnxAExrfNKtD0MQhBP2Ik+eajzO8ErK/F1RDKzGzFHp4r0mUVenEx6ta9OsRa moBg== X-Gm-Message-State: AOAM532uR3guJj6f72nNIi6lRXp8QyoiRsCfE06uwWpQWx3X87JKzU+T yyrWgu5hocfO2CJFyzU5tn6tK9LeCzQ= X-Google-Smtp-Source: ABdhPJwlk+9JqZcr/Ofxh6QtZ2/DlJL/bMu+ieNb2DerIfMS4Yv0JlmuCCuKIvDuX4Ul1zO+b8/3wQ== X-Received: by 2002:a05:6000:1290:: with SMTP id f16mr2486434wrx.298.1610093767804; Fri, 08 Jan 2021 00:16:07 -0800 (PST) Received: from localhost (131-199-28-81.ftth.cust.kwaoo.net. [81.28.199.131]) by smtp.gmail.com with ESMTPSA id m11sm10842416wmi.16.2021.01.08.00.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 00:16:06 -0800 (PST) From: Samuel Loury To: Org-mode Subject: Make org-mode multi line shell session work sensibly Date: Fri, 08 Jan 2021 09:15:57 +0100 Message-ID: <875z47c08y.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=konubinix@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.65 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=mdDF8+Ec; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 0D200940416 X-Spam-Score: -2.65 X-Migadu-Scanner: scn0.migadu.com X-TUID: fU5KIkuICUCj --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, I've been trying to work more and more with org-babel recently, and found out that the session in the shell block does not appear to work well. The symptom is the following: When I try to run a code block with noop lines, like comment, the output gets broken =2D-8<---------------cut here---------------start------------->8--- #+BEGIN_SRC sh :results output :exports both :session c66d4791-003d-42af-a4= e0-366f5542c604 echo a # noop echo b #+END_SRC #+RESULTS: : : a : $ b =2D-8<---------------cut here---------------end--------------->8--- Of course, I would expect =2D-8<---------------cut here---------------start------------->8--- #+RESULTS: : a : b =2D-8<---------------cut here---------------end--------------->8--- Actually, I went through the code and I think I understand why it has this behavior, see here for my analysis -> https://konubinix.eu/braindump/posts/c66d4791-003d-42af-a4e0-366f5542c604/ I tried to patch the code of org-babel-comint-with-output to make it work correctly, see here -> https://konubinix.eu/braindump/posts/25b52cc8-71f8-420f-9161-5c60030cede9/ But it feels like it is more of a work around than an elegant solution to the issue. I am already facing some corner cases and it does not handle yet the continuation lines, starting with ">". I was thinking that maybe, in org-babel-sh-evaluate, instead of sending the lines one by one and interpreting the result, the code could write a temporary file with the body and source it. Basically all the evaluation would be =2D-8<---------------cut here---------------start------------->8--- $ source tmp-file-XXXX $ echo org-babel-sh-eoe =2D-8<---------------cut here---------------end--------------->8--- It still would suffer from the no newline behavior I am describing here =2D> https://konubinix.eu/braindump/posts/f6206181-09d2-4449-b437-960be2b5d= fd2/ But, one step at a time, right? Then I took though about it. I cannot believe I am the only person trying to run multi line shell programs with comment in session, am I? So here are a few questions: Is there anyone with the same use case as I have? If so, how do you cope with the problem I am facing? If I want to fix it, what do you think would be the more elegant solution: fixing the line by line parsing like I was trying to do or sourcing the code to avoid using line by line parsing? org-mode is really great, org-babel is awesome and I use it more and more in my daily life, I hope we will be able to fix this annoying behavior together. Thank you for your time, My best, PS: the real life use case I am using is the following one: I want to have a few org-babel snippets to ease my code reviews, as presented in here: https://konubinix.eu/braindump/posts/564621c3-4a9a-4574-abf8-bd9831b29aa4/ the first snippet has the following output =2D-8<---------------cut here---------------start------------->8--- :=20 : $ $ $ $ $ Ready to make the review of XXX on top of YYY =2D-8<---------------cut here---------------end--------------->8--- instead of the expected =2D-8<---------------cut here---------------start------------->8--- : Ready to make the review of XXX on top of YYY =2D-8<---------------cut here---------------end--------------->8--- And the second one with the header ":results output file", have the following result =2D-8<---------------cut here---------------start------------->8--- [[file: the-directory/diff.diff]] =2D-8<---------------cut here---------------end--------------->8--- instead of the expected =2D-8<---------------cut here---------------start------------->8--- [[file:the-directory/diff.diff]] =2D-8<---------------cut here---------------end--------------->8--- With my workaround, the output is ok. =2D-=20 Konubinix GPG Key : 7439106A Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEWZO+etpl4tkGzlw2ddI87XQ5EGoFAl/4FL4ACgkQddI87XQ5 EGrF0Qf/ST82ktti1zLi3NBj9TkFJJ2y2NOaN3oSE4iwgjyJfkREgulV5MsikYpZ bf542It6joqPZIuUZSSdaW+dUiGjqQYbpvRgTkt9gAwYuawfM0vygWx0DqGjil05 xV/KV0/AyegC8vww6nC+p9+gDAMO0gQXTHMfecV1u4P/TWVEBQFhDkl2a3rPkO8T O/Rf6UF4nHu4vLbs0FP1cQsN9gSSDzOcqk/lwZB779MdyLAGcP8X7/8bZUaoK/o+ xDmrrsyTB8j20zbLxtKG0emIyKT7emXh/sJ3tzFlp/KuZSXBgNyr/XAU75j4sfBq 2+pRE5SSj1xFXmhz7jLVX+8oh8/o9Q== =V74K -----END PGP SIGNATURE----- --=-=-=--