From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id kKN4Dfo36WPkQAEAbAwnHQ (envelope-from ) for ; Sun, 12 Feb 2023 20:03:22 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id SAh/Dfo36WMUNAEAauVa8A (envelope-from ) for ; Sun, 12 Feb 2023 20:03:22 +0100 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 CEA0D24B8B for ; Sun, 12 Feb 2023 20:03:21 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRHcK-0006zN-DO; Sun, 12 Feb 2023 14:02:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRHcI-0006z7-Bz for emacs-orgmode@gnu.org; Sun, 12 Feb 2023 14:02:26 -0500 Received: from sender3-op-o19.zoho.com ([136.143.184.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRHcG-00009Y-Kw for emacs-orgmode@gnu.org; Sun, 12 Feb 2023 14:02:26 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1676228541; cv=none; d=zohomail.com; s=zohoarc; b=O1cp8jvaY5xfI6eUe8nbRhirCOKTTZHuUf1EIbk2yTEzh7ZgLKKSpRjXlN6TtsKCIa456teh5y3LtkdWmnmZdwGx062aoalY2sK3TuhJ3QPz0YozER27y1ACfUgiznzNhfsNDyrt+9MG2SphjbDC9XFRj43LduieutZqyzD6BoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676228541; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=X8wj756PvDmRhtid1k3kc/9UnTFaPDyNiGNqzlNBeYI=; b=Y34ClziuZVnzhHAY5Bb7TpPybLWAnzLTMzYXRVMAfizASRRnewG8h2NSuxsvuPh13D4Yu66ZNRSql88EV9Xiel/NhzM7dfKrad4+raBpf98cwPmlk2qbM6wZ8Gaiviqcq/pCPSqIq1knKcj5TEqEYYiNRvYdWhMRdTb+oDIzkWo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=excalamus.com; spf=pass smtp.mailfrom=matt@excalamus.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1676228541; s=zmail; d=excalamus.com; i=matt@excalamus.com; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=X8wj756PvDmRhtid1k3kc/9UnTFaPDyNiGNqzlNBeYI=; b=gc8CKyYjPfBomN1w5Httpcsyi14p/9SGBMzFBHnPh3Cty7F+2boSHuhOul6Glu2U Ew8+ItctLAeOptW5nPSgo3ITOPpbXhgT1MQLjt420matO3wLsT4gCLUDMRKJJjisqHq WV8UhOXDfgRokoOnKd5CQ8LB+vnLG9Jlyk3WEabc= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1676228539591224.67238305725925; Sun, 12 Feb 2023 11:02:19 -0800 (PST) Date: Sun, 12 Feb 2023 14:02:19 -0500 From: Matt To: "jackkamm" Cc: "emacs-orgmode" Message-ID: <1864701b4b8.e37160d6373275.4308190093579612690@excalamus.com> In-Reply-To: <87a61j3orj.fsf@gmail.com> References: <186283d230a.129f5feb61660123.3289004102603503414@excalamus.com> <87a61j3orj.fsf@gmail.com> Subject: Re: [PATCH] Async evaluation in ob-shell MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail Received-SPF: pass client-ip=136.143.184.19; envelope-from=matt@excalamus.com; helo=sender3-op-o19.zoho.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, 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.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=2; s=key1; d=yhetil.org; t=1676228601; a=rsa-sha256; cv=pass; b=oEgp8EUQpOFhhNm8Phbh75sTqrtjdVYves8QZwyhGpQBXRGOHGQN71bfOXX7LGxkiNpNyx a014XjpuUdaSj1w1Ck4DJB1bckFlZR1loKNBf2C5/uWqwf0thl7+0M61/llKbODChRWKna 9LCAr+jSCbA5A0ogXGYoPsh3wAnC6z4v3yefxYImgtyR4KYoJ6QHa6DFg1KfYl/7BBiw2w cW0qfwgeNpCjPGkyNWlpjnmP1pFSc97qTQJf0doehNoLJe/WK+ov7JD/xQj0z+BU3sDWVu eIuz2WvQJXH2Kgzz3XJ/ufaf4Om2xIoiB8Xz+Evf4OfXKE/drx5JV9Bl+ud1jw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=excalamus.com header.s=zmail header.b=gc8CKyYj; dmarc=none; arc=pass ("zohomail.com:s=zohoarc:i=1"); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676228601; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=X8wj756PvDmRhtid1k3kc/9UnTFaPDyNiGNqzlNBeYI=; b=QBmE2c2Ipv/KjRCDJjZb+wpc9EO100pkVkYqliz0ETqafT0ilUt646RHXZ9EsHCug9AMaQ KtehCu15tw23waS7wOk8KPAUcnaOyPEc7LTO27YFgQh7N6rqYD9ejSixAnv4nlCs4lM5jH u/nRr8bEWgEdgXFB9CDNbJyNDmkiw5O0+SDJeoSPlI5l43McHsYv9oK8EC9mNMiGwNjgt6 Q3i0SXGUacxpY6D9nJ1rbBu++x996QCwIS6DgQW2KVutjuGBpdgGB0d+QSbIWWESeQxDOF FPOK2EzfqngoEOCBL9gLaIce3RjNGcBezJqZUV3CVmbcFJKTG3NkLeyTDRZ9vw== X-Migadu-Queue-Id: CEA0D24B8B Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=excalamus.com header.s=zmail header.b=gc8CKyYj; dmarc=none; arc=pass ("zohomail.com:s=zohoarc:i=1"); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -8.36 X-Spam-Score: -8.36 X-TUID: TLIGl8nBbfIW ---- On Sat, 11 Feb 2023 15:56:00 -0500 wrote --- > org-babel-comint-async-filter is capable of taking a similar approach, > and reading/writing to tempfile. There is some precedence in ob-shell for this. Currently, the cmdline, stdin, and shebang headers use temp files. It may be that implementing async versions of these could use this part of the async API. However, cmdline, stdin, and shebang each use a temporary shell process rather than a dedicated comint, even when the :session header is present. The async implementation requires a comint buffer. > I believe this approach would be > generally more robust, but the major weakness is that it would break if > you SSH'd to a remote host in the middle of the session. Good point. > There was an interesting patch to ob-shell that was never applied, that > took the approach of wrapping the code block in a bash function before > executing; I think it might be a promising approach: > > https://lists.gnu.org/archive/html/emacs-orgmode/2020-02/msg00923.html This is interesting. Thanks for sharing! Instead of writing to a temp file, it could use a here document. Here documents, AFAIK, are POSIX portable, although function definitions aren't. Of course, if we're considering Windows cmd (as we did in a recent bug report), there are all sorts of problems: batch syntax (executed from a file) is different than CLI syntax, functions will implemented using labels (I'm not sure how robust that is), and no here documents. A comint would probably be best for the Windows use-case. ahab@pequod ~$ guix shell dash ahab@pequod ~ [env]$ dash <<- EOF my_function() { echo "hello, world!"; echo "the end"; } my_function; EOF hello, world! the end ahab@pequod ~$ guix shell fish ahab@pequod ~ [env]$ fish <<- EOF > function my_function > echo "hello, world!" > echo "the end" > end > my_function > EOF hello, world! the end > By the way, I took a look at ob-shell for the first time in awhile, and > noticed that ob-shell now forces the prompt to be like: > > org_babel_sh_prompt> > > Which I think makes cleaning up the prompt markers a lot more > robust. But it is a bit ugly, and also seems to break working with shell > sessions started outside of Babel with M-x shell. Is this something you consider a bug?