summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2014-02-09 20:12:18 -0700
committerEric Schulte <schulte.eric@gmail.com>2014-02-09 20:13:39 -0700
commitb896bd43ad05cf22e8451c117048f269f1fcab18 (patch)
treed7f3f8970b582814b229c24bd3b95f629c936bf7
parent05cd942f3140e4935e44d28dbde46e16daf6d606 (diff)
downloadorg-mode-b896bd43ad05cf22e8451c117048f269f1fcab18.tar.gz
add :cmdline support to shell code blocks
* lisp/ob-shell.el (org-babel-execute:shell): Pass the cmdline header argument to `org-babel-sh-evaluate'. (org-babel-sh-evaluate): Pass the cmdline header argument to `call-process-shell-command'.
-rw-r--r--lisp/ob-shell.el11
1 files changed, 6 insertions, 5 deletions
diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 9e4a222..0560f48 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -75,10 +75,11 @@ This function is called by `org-babel-execute-src-block'."
(stdin (let ((stdin (cdr (assoc :stdin params))))
(when stdin (org-babel-sh-var-to-string
(org-babel-ref-resolve stdin)))))
+ (cmdline (cdr (assoc :cmdline 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 params stdin)
+ (org-babel-sh-evaluate session full-body params stdin cmdline)
(org-babel-pick-name
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
(org-babel-pick-name
@@ -149,14 +150,14 @@ Emacs-lisp table, otherwise return the results as a string."
(defvar org-babel-sh-eoe-output "org_babel_sh_eoe"
"String to indicate that evaluation has completed.")
-(defun org-babel-sh-evaluate (session body &optional params stdin)
+(defun org-babel-sh-evaluate (session body &optional params stdin cmdline)
"Pass BODY to the Shell process in BUFFER.
If RESULT-TYPE equals 'output then return a list of the outputs
of the statements in BODY, if RESULT-TYPE equals 'value then
return the value of the last statement in BODY."
(let ((results
(cond
- (stdin ; external shell script w/STDIN
+ ((or stdin cmdline) ; external shell script w/STDIN
(let ((script-file (org-babel-temp-file "sh-script-"))
(stdin-file (org-babel-temp-file "sh-stdin-"))
(shebang (cdr (assoc :shebang params)))
@@ -166,14 +167,14 @@ return the value of the last statement in BODY."
(when padline (insert "\n"))
(insert body))
(set-file-modes script-file #o755)
- (with-temp-file stdin-file (insert stdin))
+ (with-temp-file stdin-file (insert (or stdin "")))
(with-temp-buffer
(call-process-shell-command
(if shebang
script-file
(format "%s %s" org-babel-sh-command script-file))
stdin-file
- (current-buffer))
+ (current-buffer) nil cmdline)
(buffer-string))))
(session ; session evaluation
(mapconcat