[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals-release/org c42cdcda47 2/2: lisp/ob-shell.el: Adapt the
From: |
ELPA Syncer |
Subject: |
[elpa] externals-release/org c42cdcda47 2/2: lisp/ob-shell.el: Adapt the `:var' header parameter to fish |
Date: |
Sun, 15 Oct 2023 06:58:40 -0400 (EDT) |
branch: externals-release/org
commit c42cdcda4789122c3c8ed477365b9369bdf0af87
Author: Elias Kueny <elias.kueny@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
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 2c30a26056..87e38e414c 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -166,6 +166,11 @@ This function is called by `org-babel-execute-src-block'."
"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."
@@ -211,8 +216,11 @@ This function is called by `org-babel-execute-src-block'."
(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)