diff options
authorAchim Gratz <Stromeko@Stromeko.DE>2014-06-22 09:16:41 (GMT)
committer Achim Gratz <Stromeko@Stromeko.DE>2014-06-23 18:53:22 (GMT)
commit6d15cd3b89cb665357ef1f6e62c8687a10b911b4 (patch)
parent2685f31a506e368aef86edbb71a5ae15438610ef (diff)
ob-shell: honor the specified shell for :session
* lisp/ob-shell.el: Remove defcustom `org-babel-sh-command' and replace with `shell-file-name' throughout. (org-babel-variable-assignments:sh): Make check for bash work in more cases. The original code and the patched version rely on the shell being available via PATH. Instead the shell name should be mapped to the appropriate executable via an alist and invoked via an absolute filename. For security reasons the permissible shells should probably be taken from /etc/shells or equivalent by default. Instead of checking for bash, the same or another alist could provide the information of whether or not the shell supports arrays (which indeed were introduced by ksh originally).
1 files changed, 4 insertions, 11 deletions
diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 7d87026..8c58dfd 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -38,13 +38,6 @@
(defvar org-babel-default-header-args:sh '())
-(defcustom org-babel-sh-command shell-file-name
- "Command used to invoke a shell.
-Set by default to the value of `shell-file-name'. This will be
-passed to `shell-command-on-region'"
- :group 'org-babel
- :type 'string)
(defcustom org-babel-shell-names
'("sh" "bash" "csh" "ash" "dash" "ksh" "mksh" "posh")
"List of names of shell supported by babel shell code blocks."
@@ -57,7 +50,7 @@ passed to `shell-command-on-region'"
(lambda (name)
(eval `(defun ,(intern (concat "org-babel-execute:" name)) (body params)
,(format "Execute a block of %s commands with Babel." name)
- (let ((org-babel-sh-command ,name))
+ (let ((shell-file-name ,name))
(org-babel-execute:shell body params)))))
(second value))))
@@ -144,7 +137,7 @@ This function is called by `org-babel-execute-src-block'."
(lambda (pair)
- (if (string= org-babel-sh-command "bash")
+ (if (string-match "bash$" shell-file-name)
(car pair) (cdr pair) sep hline)
@@ -211,7 +204,7 @@ return the value of the last statement in BODY."
(if shebang
- (format "%s %s" org-babel-sh-command script-file))
+ (format "%s %s" shell-file-name script-file))
(current-buffer) nil cmdline)
@@ -249,7 +242,7 @@ return the value of the last statement in BODY."
(insert body))
(set-file-modes script-file #o755)
(org-babel-eval script-file ""))
- (org-babel-eval org-babel-sh-command (org-babel-trim body)))))))
+ (org-babel-eval shell-file-name (org-babel-trim body)))))))
(when results
(let ((result-params (cdr (assoc :result-params params))))
(org-babel-result-cond result-params