summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-10-15 09:25:33 -0600
committerEric Schulte <schulte.eric@gmail.com>2010-10-15 09:25:33 -0600
commitc9b017632eefdb40da3632c191c5c2321eff1569 (patch)
tree3750a2aebd95d360db6a9cd1125c6eacabb86b9a
parent1ff357d59fe2b74c19302cf1dce76f86d9fa6805 (diff)
downloadorg-mode-c9b017632eefdb40da3632c191c5c2321eff1569.tar.gz
ob-sh: no longer fails on empty results
* lisp/ob-sh.el (org-babel-sh-evaluate): no longer assumes that results are non-nil
-rw-r--r--lisp/ob-sh.el13
-rw-r--r--testing/lisp/test-ob-sh.el5
2 files changed, 12 insertions, 6 deletions
diff --git a/lisp/ob-sh.el b/lisp/ob-sh.el
index 573a712..20dde69 100644
--- a/lisp/ob-sh.el
+++ b/lisp/ob-sh.el
@@ -152,12 +152,13 @@ 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."
((lambda (results)
- (if (or (member "scalar" result-params)
- (member "output" result-params))
- results
- (let ((tmp-file (org-babel-temp-file "sh-")))
- (with-temp-file tmp-file (insert results))
- (org-babel-import-elisp-from-file tmp-file))))
+ (when results
+ (if (or (member "scalar" result-params)
+ (member "output" result-params))
+ results
+ (let ((tmp-file (org-babel-temp-file "sh-")))
+ (with-temp-file tmp-file (insert results))
+ (org-babel-import-elisp-from-file tmp-file)))))
(if (not session)
(org-babel-eval org-babel-sh-command (org-babel-trim body))
(mapconcat
diff --git a/testing/lisp/test-ob-sh.el b/testing/lisp/test-ob-sh.el
index 36846c1..929bac5 100644
--- a/testing/lisp/test-ob-sh.el
+++ b/testing/lisp/test-ob-sh.el
@@ -29,6 +29,11 @@ unless the body of the tangled block does."
(should (string-match "^[\n\r][\t ]*[\n\r]"
(org-babel-expand-body:sh "\n\necho 2" '()))))
+(ert-deftest test-ob-sh/dont-error-on-empty-results ()
+ "Was throwing an elisp error when shell blocks threw errors and
+returned empty results."
+ (should (null (org-babel-execute:sh "ls NoSuchFileOrDirectory.txt" nil))))
+
(provide 'test-ob-sh)
;;; test-ob-sh.el ends here