ob-sh: no longer fails on empty results

* lisp/ob-sh.el (org-babel-sh-evaluate): no longer assumes that
  results are non-nil
This commit is contained in:
Eric Schulte 2010-10-15 09:25:33 -06:00
parent 1ff357d59f
commit c9b017632e
2 changed files with 12 additions and 6 deletions

View File

@ -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

View File

@ -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