babel: shell: New variable assignment and expansion scheme
* ob-sh.el (org-babel-execute:sh): Use generic expansion function (org-babel-expand-body:sh): Delete function (org-babel-prep-session:sh): Change name of called function (org-babel-variable-assignments:sh): Change function name
This commit is contained in:
parent
19081f12f7
commit
07c84b293c
|
@ -45,19 +45,14 @@
|
|||
"Command used to invoke a shell.
|
||||
This will be passed to `shell-command-on-region'")
|
||||
|
||||
(defun org-babel-expand-body:sh (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(mapconcat #'identity
|
||||
(append (org-babel-sh-variable-assignments params) (list body))
|
||||
"\n"))
|
||||
|
||||
(defun org-babel-execute:sh (body params)
|
||||
"Execute a block of Shell commands with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (org-babel-sh-initiate-session (nth 0 processed-params)))
|
||||
(result-params (nth 2 processed-params))
|
||||
(full-body (org-babel-expand-body:sh body params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params (org-babel-variable-assignments:sh params))))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-sh-evaluate session full-body result-params)
|
||||
(org-babel-pick-name
|
||||
|
@ -68,7 +63,7 @@ This function is called by `org-babel-execute-src-block'."
|
|||
(defun org-babel-prep-session:sh (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((session (org-babel-sh-initiate-session session))
|
||||
(var-lines (org-babel-sh-variable-assignments params)))
|
||||
(var-lines (org-babel-variable-assignments:sh params)))
|
||||
(org-babel-comint-in-buffer session
|
||||
(mapc (lambda (var)
|
||||
(insert var) (comint-send-input nil t)
|
||||
|
@ -86,7 +81,7 @@ This function is called by `org-babel-execute-src-block'."
|
|||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-sh-variable-assignments (params)
|
||||
(defun org-babel-variable-assignments:sh (params)
|
||||
"Return list of shell statements assigning the block's variables"
|
||||
(let ((sep (cdr (assoc :separator params))))
|
||||
(mapcar
|
||||
|
|
Loading…
Reference in New Issue