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 ms0.migadu.com with LMTPS id CESQGcWGkmHusgAAgWs5BA (envelope-from ) for ; Mon, 15 Nov 2021 17:11:49 +0100 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 WF9HFcWGkmF1UAAA1q6Kng (envelope-from ) for ; Mon, 15 Nov 2021 16:11: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 DB15A2F0CB for ; Mon, 15 Nov 2021 17:11:47 +0100 (CET) Received: from localhost ([::1]:42718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmeaA-0004I5-I8 for larch@yhetil.org; Mon, 15 Nov 2021 11:11:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmeZ3-0004DP-TR for emacs-orgmode@gnu.org; Mon, 15 Nov 2021 11:10:38 -0500 Received: from [2001:67c:2050::465:103] (port=24592 helo=mout-p-103.mailbox.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1mmeZ1-0001Db-M6 for emacs-orgmode@gnu.org; Mon, 15 Nov 2021 11:10:37 -0500 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:105:465:1:3:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4HtDgJ1kvDzQkm0 for ; Mon, 15 Nov 2021 17:10:20 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kraus.my; s=MBO0001; t=1636992617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8FV3j0pmv/6NauvSiT0lqXjMcdTxPIMz/85h5IdkBLA=; b=1uSc6MX5+forvio2QI8yabGX8F0eUOuNHHOtTJ0LbMxTBIyQlQ6B1XouGsrlbRO+J2pUAJ sY0rzTfbZhfdAoJvdUVIiHLwDV/70pbo38lJZS+KaVlVtMRWDX+5BqvpQLcLMgW3jT97ta 6bqADv3qQEud9dvCmqgU8NHBh2383pANffCVbmHtcZZuxiB6EtNwpLYS0xJkmK87UCLhyP EzcZqWjM4gzEUbehl/XxZwpFqhc6xbVVvE2HSFy5+l4b9rX7+PfrqNEWMH7ZVAGTkWvGkD KYHfm0+GOo0mpOeQw00uEpXMFNywDyk+DKhVQ0QFxEZPH74iy4/kuTmOORFO9A== References: <87bl2mycxq.fsf@kraus.my> <87v90u66et.fsf@kraus.my> From: Daniel Kraus To: emacs-orgmode@gnu.org Subject: Re: [PATCH] ob-clojure.el: Add support for babashka and nbb backend Date: Mon, 15 Nov 2021 17:05:43 +0100 In-reply-to: Message-ID: <87o86lo0wv.fsf@kraus.my> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:67c:2050::465:103 (failed) Received-SPF: none client-ip=2001:67c:2050::465:103; envelope-from=daniel@kraus.my; helo=mout-p-103.mailbox.org X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 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_LOW=-0.7, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1636992708; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=8FV3j0pmv/6NauvSiT0lqXjMcdTxPIMz/85h5IdkBLA=; b=Pr2seRyJOnrNb8yNakPlRprW0aNxuGi/uCnJxXqsRqYFJnzTR2C/9NKb5FoahnxoZgldb8 5Rs/cyhyO7rBBQSzWUt821MnAyyiFT6zYl/5tf1Ijm3tPCC/5285dDNRP/UM/VqoRp4J4K zCJLbWQLEaC2mpxVKH8ccEiQWulWeR9vnBajt2MlKk3r39ZKQ+XB5FiTAEq9PW2HrDEspl e209qXqtpH6+m801mp6UlD3y+1DqNWVLv/LnaG3nr4IkkfJQucWDKwuRLdERbBAwOSsnxs Gmsp5Kch3rekNoHEE07PRIjqspKlym4ht3hIEoHqvx+UxLbAn/A6cDec99PjhA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1636992708; a=rsa-sha256; cv=none; b=lAgLk09yTwdyOYnrTCSiyMSRyju8jAGakFx7jL8jdqQTej2YRewN5lYqZnw+gzFdN6FkNi xp+/87mansJLLgq50xFW1gCw5jmUvgUmK3BleiMTiwhub9skYYItY5LidZNkS/VWRBCQAk 22K6ErfO000ycHQiEqhVUYzrt+FxqH/zzrcgVpYvUlgTwqf22EC5eIAMacGZFnk2sVDH2r QktpjPiZttQr6SHIVA7uK9VGiuTBxWEB09aUZxVioEFfUfKEVFiGJZsATyXk9VnhCUq4Mz X7bZjSweTcgYvEshO/+/GTFcs/cwWd7Ba6uwJR0XafiY1sVta/onmKkx0WKDCw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=kraus.my header.s=MBO0001 header.b=1uSc6MX5; 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-Spam-Score: -3.64 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=kraus.my header.s=MBO0001 header.b=1uSc6MX5; 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-Queue-Id: DB15A2F0CB X-Spam-Score: -3.64 X-Migadu-Scanner: scn0.migadu.com X-TUID: zeEteCcAg2Px --=-=-= Content-Type: text/plain Max Nikulin writes: > The following source block must not execute echo and touch > > #+begin_src clojure > (str "`echo $HOME`" "`touch /tmp/pwned`") > #+end_src Thanks, now I got it :) Attached is the patch changed the logic to use a temp file with org-babel-eval. Somehow it doesn't feel too great to create unnecessary temp files but I looked how other babel backends do it and e.g. ob-js and ob-haskell use the same logic. Thanks, Daniel --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-clojure.el-Add-support-for-babashka-and-nbb-backe.patch >From cc9a24fcc42756cc76d59697bddc94a4ee2c475d Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sat, 13 Nov 2021 22:51:56 +0100 Subject: [PATCH] ob-clojure.el: Add support for babashka and nbb backend * lisp/ob-clojure.el: Add support for babashka and nbb backend. --- lisp/ob-clojure.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index 3b995d94c..8548dc86d 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -36,6 +36,8 @@ ;; For clojure-mode, see https://github.com/clojure-emacs/clojure-mode ;; For cider, see https://github.com/clojure-emacs/cider ;; For inf-clojure, see https://github.com/clojure-emacs/cider +;; For babashka, see https://github.com/babashka/babashka +;; For nbb, see https://github.com/babashka/nbb ;; For SLIME, the best way to install these components is by following ;; the directions as set out by Phil Hagelberg (Technomancy) on the @@ -73,6 +75,8 @@ (const :tag "inf-clojure" inf-clojure) (const :tag "cider" cider) (const :tag "slime" slime) + (const :tag "babashka" babashka) + (const :tag "nbb" nbb) (const :tag "Not configured yet" nil))) (defcustom org-babel-clojure-default-ns "user" @@ -80,6 +84,16 @@ :type 'string :group 'org-babel) +(defcustom ob-clojure-babashka-command (executable-find "bb") + "Path to the babashka executable." + :type 'file + :group 'org-babel) + +(defcustom ob-clojure-nbb-command (executable-find "nbb") + "Path to the nbb executable." + :type 'file + :group 'org-babel) + (defun org-babel-expand-body:clojure (body params) "Expand BODY according to PARAMS, return the expanded body." (let* ((vars (org-babel--get-vars params)) @@ -225,6 +239,15 @@ ,(buffer-substring-no-properties (point-min) (point-max))) (cdr (assq :package params))))) +(defun ob-clojure-eval-with-babashka (bb expanded) + "Evaluate EXPANDED code block using BB (babashka or nbb)." + (let ((script-file (org-babel-temp-file "clojure-bb-script-" ".clj"))) + (with-temp-file script-file + (insert expanded)) + (org-babel-eval + (format "%s %s" bb (org-babel-process-file-name script-file)) + ""))) + (defun org-babel-execute:clojure (body params) "Execute a block of Clojure code with Babel." (unless org-babel-clojure-backend @@ -236,6 +259,10 @@ (cond ((eq org-babel-clojure-backend 'inf-clojure) (ob-clojure-eval-with-inf-clojure expanded params)) + ((eq org-babel-clojure-backend 'babashka) + (ob-clojure-eval-with-babashka ob-clojure-babashka-command expanded)) + ((eq org-babel-clojure-backend 'nbb) + (ob-clojure-eval-with-babashka ob-clojure-nbb-command expanded)) ((eq org-babel-clojure-backend 'cider) (ob-clojure-eval-with-cider expanded params)) ((eq org-babel-clojure-backend 'slime) -- 2.33.1 --=-=-=--