Bläddra i källkod

ob-shell.el: Use the exit status as the default result

* lisp/ob-shell.el (org-babel-execute:shell)
(org-babel-sh-evaluate): Use the exit code as the value and,
consequently, as the result when no :results header is set.

See this thread:
https://orgmode.org/list/CA+A2iZaziAfMeGpBqL6qGrzrWEVvLvC0DUw++T4gCF3NGuW-DQ@mail.gmail.com/

And Tim's useful summary here:
https://orgmode.org/list/87sgiszqc1.fsf@gmail.com/

This commit resolves the issue by deciding not to make an exception
for ob-shell.el:

- the "value" of executing a shell/bash script is the exit code
- when no :results header is set, use the value as the result
- use :results output to use the stdout
Bastien 4 år sedan
förälder
incheckning
2f53429413
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2 2
      lisp/ob-shell.el

+ 2 - 2
lisp/ob-shell.el

@@ -80,7 +80,7 @@ This function is called by `org-babel-execute-src-block'."
                   (when stdin (org-babel-sh-var-to-string
                                (org-babel-ref-resolve stdin)))))
 	 (value-is-exit-status
-	  (member "value" (cdr (assq :result-params params))))
+	  (not (member "output" (cdr (assq :result-params params)))))
 	 (cmdline (cdr (assq :cmdline params)))
          (full-body (concat
 		     (org-babel-expand-body:generic
@@ -214,7 +214,7 @@ of the statements in BODY, if RESULT-TYPE equals `value' then
 return the value of the last statement in BODY."
   (let* ((shebang (cdr (assq :shebang params)))
 	 (value-is-exit-status
-	  (member "value" (cdr (assq :result-params params))))
+	  (not (member "output" (cdr (assq :result-params params)))))
 	 (results
 	  (cond
 	   ((or stdin cmdline)	       ; external shell script w/STDIN