From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IB7dG5NyKmXO/QAAauVa8A:P1 (envelope-from ) for ; Sat, 14 Oct 2023 12:50:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IB7dG5NyKmXO/QAAauVa8A (envelope-from ) for ; Sat, 14 Oct 2023 12:50:59 +0200 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 2999A6B2ED for ; Sat, 14 Oct 2023 12:50:59 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=atvCmjaP; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1697280659; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=C4kYGQrvbapzxCewxdZp4x2NDa3edK1Ja62Ek5sTFQA=; b=V93uvLZhN6hKBvqWlQCpGIQG8KM7DUrc+8PAuYkh7zcAKTzWxj6mtpIZFm7+lC9QhB9GPS qxWoMlrEnS+KbWpaJpaRTq+nwfGrg2SGjXJI/RQaN8tQC6UUqNZjo61UK6nqgkuf8Dwq5p INqmiBEYpi+t/TQLiaJsis+cqbVgO9IARMkmqHpzvfmvy4z2MO1KgZSNoyuVg/jxy98LqS ksMGtWEECoN2RnfXUvviZZrxfGtRx5yqMcygNaY3nKA1kpfksp1CcIslszJWdgxZXr4yuS 9RO4NBAETN+xn848dC0Lq49tkoLc4bmtnuAAGpRaYRFOvyk7j7gdiqvfvuFoAg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1697280659; a=rsa-sha256; cv=none; b=d+GL+e47D9IvImTEcZSRFFYNfUr9AMvxZ7BfzuO7c7Cn9SIdcHBb25/EnhZbJRui0t2WE/ bX+P6oNOvdH9BopUuXVRcTGnc33VgeZxMjGFBx2X2V1xoBUN5iPjTnjALevOjLaYYicWKe 4EtLj5jtyX6bIonSFRt4gXUtT/ndCmbhxB91VdF7hoe+A5LjKahxuydXZ/X9Xe/MaNKeLI Rt38qeMJHFhq1BpiDgdQvF3MTZDVTKh0zh/W50H109DtPE4Et9/oUUwSnP9nwn8fDsgTlw kLhGxr7ietpOkh436S7E4o+jjCB4Bwd2m9WT3ma5HUzqiK02q4QW0fvo/6PfNw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=atvCmjaP; 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"; dmarc=pass (policy=none) header.from=posteo.net Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrcDh-0001YG-3w; Sat, 14 Oct 2023 06:50:09 -0400 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 1qrcDe-0001Y7-Eo for emacs-orgmode@gnu.org; Sat, 14 Oct 2023 06:50:06 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrcDZ-0004oS-Bg for emacs-orgmode@gnu.org; Sat, 14 Oct 2023 06:50:04 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 64B32240101 for ; Sat, 14 Oct 2023 12:49:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1697280597; bh=YbXKe1Iwp/sNADwkJsNO4+BE5/JykspEVCxaFSCOTXw=; h=From:To:Subject:Date:Message-ID:MIME-Version:From; b=atvCmjaPuV72972JuBFVYFcGUtycNJjYTUTbQJsdAbLPVccnExEAuJwpizhZf+pvr ej0VEH0MPxthjkS2AzD9AEB+pmJAZ37ilL3J9uxd+GSE0Mx0qpF3ZirNcbn1T6d9FW NRsCkylyH+xuDcS5BbkBPcFfeS7mGCmIKzUplok3jKjtFp7aGaYmyz4YKL8alC3fuy 3yqzpDHy2eh9CJc8dlkn9RAMBpGOXmzPKOqcFyCsfzEGGKlS5f0xbYWLqtWfa0JIV6 al9AL5Fk89Md/lPZoj7y8yOkbLOhrfLOA9PrN+GovS5tRqB1hP5NNe96tNO0c8IBBK oXEsl3/gSTrUg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S70WS6g28z6tvp for ; Sat, 14 Oct 2023 12:49:56 +0200 (CEST) From: Elias Kueny To: emacs-orgmode@gnu.org Subject: [PATCH] Fix :var parameter for fish shell code blocks Date: Fri, 13 Oct 2023 22:42:52 +0000 Message-ID: <877cnpwka3.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=elias.kueny@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 X-Spam-Score: -9.88 X-Migadu-Queue-Id: 2999A6B2ED X-Migadu-Scanner: mx0.migadu.com X-Migadu-Spam-Score: -9.88 X-TUID: Gb+CAMXrVPFh --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-ob-shell.el-Adapt-the-var-header-parameter-to-f.patch >From 0d8067348d033e159a460233773e442c0775a8bb Mon Sep 17 00:00:00 2001 From: Elias Kueny Date: Sat, 14 Oct 2023 00:20:55 +0200 Subject: [PATCH] lisp/ob-shell.el: Adapt the `:var' header parameter to fish * ob-shell.el (org-babel-variable-assignments:shell): allow the `:var' keyword on fish code blocks to work with fish variables. The fish shell uses the syntax `set variable value' instead of `value=value' to set a shell variable. This caused org-babel to return an syntax error when attempting to execute a fish code block with a `:var' parameter. This change adds a helper function to use the correct format. TINYCHANGE --- lisp/ob-shell.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el index fe4c7af72..9f3b614e6 100644 --- a/lisp/ob-shell.el +++ b/lisp/ob-shell.el @@ -167,6 +167,11 @@ defun org-babel--variable-assignments:sh-generic "Return a list of statements declaring the values as a generic variable." (format "%s=%s" varname (org-babel-sh-var-to-sh values sep hline))) +(defun org-babel--variable-assignments:fish + (varname values &optional sep hline) + "Return a list of statements declaring the values as a fish variable." + (format "set %s %s" varname (org-babel-sh-var-to-sh values sep hline))) + (defun org-babel--variable-assignments:bash_array (varname values &optional sep hline) "Return a list of statements declaring the values as a bash array." @@ -212,8 +217,11 @@ defun org-babel-variable-assignments:shell (if (string-suffix-p "bash" shell-file-name) (org-babel--variable-assignments:bash (car pair) (cdr pair) sep hline) - (org-babel--variable-assignments:sh-generic - (car pair) (cdr pair) sep hline))) + (if (string-suffix-p "fish" shell-file-name) + (org-babel--variable-assignments:fish + (car pair) (cdr pair) sep hline) + (org-babel--variable-assignments:sh-generic + (car pair) (cdr pair) sep hline)))) (org-babel--get-vars params)))) (defun org-babel-sh-var-to-sh (var &optional sep hline) -- 2.41.0 --=-=-= Content-Type: text/plain; format=flowed Hello, I found an issue with fish shell code blocks, in that the `:var' parameter generates a command that is not syntaxically correct. Fish uses `set variable value' instead of `variable = value'. As a result, org-babel throws an error when executing the code block. This patch fixes this by adding an exception to org-babel-variable-assignments:shell on the model of what it already does for bash. Example of code block triggering the error: #+begin_src fish :var test echo $test #+end_src Best regards, Elias --=-=-=--