ob-shell.el: Delete `org-babel-shell-return-value-is-exit-status'

* lisp/ob-shell.el (org-babel-sh-evaluate): Return the output
by default.  Return exit status as the "value" when :result is
explicitely set to "value".

* lisp/ob-shell.el
(org-babel-shell-return-value-is-exit-status): Delete option.

* doc/org-manual.org (Collection): Be more accurate.

See the whole thread here:
https://lists.gnu.org/archive/html/emacs-orgmode/2020-02/msg00715.html

Thanks to everyone in this discussion.
This commit is contained in:
Bastien 2020-02-22 10:58:55 +01:00
parent 5dee070fb2
commit 08428fed78
3 changed files with 54 additions and 70 deletions

View File

@ -17274,13 +17274,13 @@ they are mutually exclusive.
- =value= ::
Default. Functional mode. Org gets the value by wrapping the code
in a function definition in the language of the source block. That
is why when using =:results value=, code should execute like
a function and return a value. For languages like Python, an
explicit ~return~ statement is mandatory when using =:results
value=. Result is the value returned by the last statement in the
code block.
Default for most Babel libraries[fn:142]. Functional mode. Org
gets the value by wrapping the code in a function definition in the
language of the source block. That is why when using =:results
value=, code should execute like a function and return a value. For
languages like Python, an explicit ~return~ statement is mandatory
when using =:results value=. Result is the value returned by the
last statement in the code block.
When evaluating the code block in a session (see [[*Environment of
a Code Block]]), Org passes the code to an interpreter running as an
@ -17873,10 +17873,10 @@ Code blocks in the following languages are supported.
| Asymptote | =asymptote= | Lisp | =lisp= |
| Awk | =awk= | Lua | =lua= |
| C | =C= | MATLAB | =matlab= |
| C++ | =C++=[fn:142] | Mscgen | =mscgen= |
| C++ | =C++=[fn:143] | Mscgen | =mscgen= |
| Clojure | =clojure= | Objective Caml | =ocaml= |
| CSS | =css= | Octave | =octave= |
| D | =D=[fn:143] | Org mode | =org= |
| D | =D=[fn:144] | Org mode | =org= |
| ditaa | =ditaa= | Oz | =oz= |
| Emacs Calc | =calc= | Perl | =perl= |
| Emacs Lisp | =emacs-lisp= | Plantuml | =plantuml= |
@ -18005,7 +18005,7 @@ for Python and Emacs Lisp languages.
#+cindex: syntax, Noweb
#+cindex: source code, Noweb reference
Org supports named blocks in Noweb[fn:144] style syntax:
Org supports named blocks in Noweb[fn:145] style syntax:
: <<CODE-BLOCK-ID>>
@ -18501,7 +18501,7 @@ Org Tempo expands snippets to structures defined in
~org-structure-template-alist~ and ~org-tempo-keywords-alist~. For
example, {{{kbd(< s TAB)}}} creates a code block. Enable it by
customizing ~org-modules~ or add =(require 'org-tempo)= to your Emacs
init file[fn:145].
init file[fn:146].
#+attr_texinfo: :columns 0.1 0.9
| {{{kbd(a)}}} | =#+BEGIN_EXPORT ascii= ... =#+END_EXPORT= |
@ -18581,7 +18581,7 @@ in the desired amount with hard spaces and hiding leading stars.
To display the buffer in the indented view, activate Org Indent minor
mode, using {{{kbd(M-x org-indent-mode)}}}. Text lines that are not
headlines are prefixed with virtual spaces to vertically align with
the headline text[fn:146].
the headline text[fn:147].
#+vindex: org-indent-indentation-per-level
To make more horizontal space, the headlines are shifted by two
@ -18609,9 +18609,9 @@ use =STARTUP= keyword as follows:
It is possible to use hard spaces to achieve the indentation instead,
if the bare ASCII file should have the indented look also outside
Emacs[fn:147]. With Org's support, you have to indent all lines to
Emacs[fn:148]. With Org's support, you have to indent all lines to
line up with the outline headers. You would use these
settings[fn:148]:
settings[fn:149]:
#+begin_src emacs-lisp
(setq org-adapt-indentation t
@ -18878,7 +18878,7 @@ changes.
#+vindex: org-startup-indented
Dynamic virtual indentation is controlled by the variable
~org-startup-indented~[fn:149].
~org-startup-indented~[fn:150].
| =indent= | Start with Org Indent mode turned on. |
| =noindent= | Start with Org Indent mode turned off. |
@ -19694,7 +19694,7 @@ Tags]]) only for those set in these variables.
#+vindex: org-mobile-directory
The mobile application needs access to a file directory on
a server[fn:150] to interact with Emacs. Pass its location through
a server[fn:151] to interact with Emacs. Pass its location through
the ~org-mobile-directory~ variable. If you can mount that directory
locally just set the variable to point to that directory:
@ -19715,7 +19715,7 @@ With a public server, consider encrypting the files. Org also
requires OpenSSL installed on the local computer. To turn on
encryption, set the same password in the mobile application and in
Emacs. Set the password in the variable
~org-mobile-use-encryption~[fn:151]. Note that even after the mobile
~org-mobile-use-encryption~[fn:152]. Note that even after the mobile
application encrypts the file contents, the file name remains visible
on the file systems of the local computer, the server, and the mobile
device.
@ -19731,15 +19731,15 @@ The command ~org-mobile-push~ copies files listed in
~org-mobile-files~ into the staging area. Files include agenda files
(as listed in ~org-agenda-files~). Customize ~org-mobile-files~ to
add other files. File names are staged with paths relative to
~org-directory~, so all files should be inside this directory[fn:152].
~org-directory~, so all files should be inside this directory[fn:153].
Push creates a special Org file =agendas.org= with custom agenda views
defined by the user[fn:153].
defined by the user[fn:154].
Finally, Org writes the file =index.org=, containing links to other
files. The mobile application reads this file first from the server
to determine what other files to download for agendas. For faster
downloads, it is expected to only read files whose checksums[fn:154]
downloads, it is expected to only read files whose checksums[fn:155]
have changed.
*** Pulling from the mobile application
@ -19756,7 +19756,7 @@ data in an inbox file format, through the following steps:
1.
#+vindex: org-mobile-inbox-for-pull
Org moves all entries found in =mobileorg.org=[fn:155] and appends
Org moves all entries found in =mobileorg.org=[fn:156] and appends
them to the file pointed to by the variable
~org-mobile-inbox-for-pull~. It should reside neither in the
staging area nor on the server. Each captured entry and each
@ -20052,9 +20052,9 @@ of these strategies:
#+cindex: @LaTeX{}, and Orgtbl mode
To wrap a source table in LaTeX, use the =comment= environment
provided by =comment.sty=[fn:156]. To activate it, put
provided by =comment.sty=[fn:157]. To activate it, put
~\usepackage{comment}~ in the document header. Orgtbl mode inserts
a radio table skeleton[fn:157] with the command {{{kbd(M-x
a radio table skeleton[fn:158] with the command {{{kbd(M-x
orgtbl-insert-radio-table)}}}, which prompts for a table name. For
example, if =salesfigures= is the name, the template inserts:
@ -20073,7 +20073,7 @@ The line =#+ORGTBL: SEND= tells Orgtbl mode to use the function
~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
the table at the target (receive) location named =salesfigures=. Now
the table is ready for data entry. It can even use spreadsheet
features[fn:158]:
features[fn:159]:
#+begin_example
% BEGIN RECEIVE ORGTBL salesfigures
@ -20289,7 +20289,7 @@ Dynamic blocks, like any other block, can be narrowed with
#+vindex: org-agenda-skip-function
#+vindex: org-agenda-skip-function-global
Org provides a special hook to further limit items in agenda views:
~agenda~, ~agenda*~[fn:159], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
~agenda~, ~agenda*~[fn:160], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
~tags-tree~. Specify a custom function that tests inclusion of every
matched item in the view. This function can also skip as much as is
needed.
@ -20332,7 +20332,7 @@ meaningful string suitable for the agenda view.
#+vindex: org-agenda-skip-function
Search for entries with a limit set on levels for the custom search.
This is a general approach to creating custom searches in Org. To
include all levels, use =LEVEL>0=[fn:160]. Then to selectively pick
include all levels, use =LEVEL>0=[fn:161]. Then to selectively pick
the matched entries, use ~org-agenda-skip-function~, which also
accepts Lisp forms, such as ~org-agenda-skip-entry-if~ and
~org-agenda-skip-subtree-if~. For example:
@ -21744,64 +21744,68 @@ to remove code evaluation from the {{{kbd(C-c C-c)}}} key binding.
are not evaluated when they appear in a keyword (see [[*Summary of
In-Buffer Settings]]).
[fn:142] C++ language is handled in =ob-C.el=. Even though the
[fn:142] For shell source blocks, the default is to return the output.
If you want to enforce returning the exit status, add =:results value=
explicitely.
[fn:143] C++ language is handled in =ob-C.el=. Even though the
identifier for such source blocks is =C++=, you activate it by loading
the C language.
[fn:143] D language is handled in =ob-C.el=. Even though the
[fn:144] D language is handled in =ob-C.el=. Even though the
identifier for such source blocks is =D=, you activate it by loading
the C language.
[fn:144] For Noweb literate programming details, see
[fn:145] For Noweb literate programming details, see
http://www.cs.tufts.edu/~nr/noweb/.
[fn:145] For more information, please refer to the commentary section
[fn:146] For more information, please refer to the commentary section
in =org-tempo.el=.
[fn:146] Org Indent mode also sets ~wrap-prefix~ correctly for
[fn:147] Org Indent mode also sets ~wrap-prefix~ correctly for
indenting and wrapping long lines of headlines or text. This minor
mode also handles Visual Line mode and directly applied settings
through ~word-wrap~.
[fn:147] This works, but requires extra effort. Org Indent mode is
[fn:148] This works, but requires extra effort. Org Indent mode is
more convenient for most applications.
[fn:148] ~org-adapt-indentation~ can also be set to ='headline-data=,
[fn:149] ~org-adapt-indentation~ can also be set to ='headline-data=,
in which case only data lines below the headline will be indented.
[fn:149] Note that Org Indent mode also sets the ~wrap-prefix~
[fn:150] Note that Org Indent mode also sets the ~wrap-prefix~
property, such that Visual Line mode (or purely setting ~word-wrap~)
wraps long lines, including headlines, correctly indented.
[fn:150] For a server to host files, consider using a WebDAV server,
[fn:151] For a server to host files, consider using a WebDAV server,
such as [[https://nextcloud.com][Nextcloud]]. Additional help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
[fn:151] If Emacs is configured for safe storing of passwords, then
[fn:152] If Emacs is configured for safe storing of passwords, then
configure the variable ~org-mobile-encryption-password~; please read
the docstring of that variable.
[fn:152] Symbolic links in ~org-directory~ need to have the same name
[fn:153] Symbolic links in ~org-directory~ need to have the same name
as their targets.
[fn:153] While creating the agendas, Org mode forces =ID= properties
[fn:154] While creating the agendas, Org mode forces =ID= properties
on all referenced entries, so that these entries can be uniquely
identified if Org Mobile flags them for further action. To avoid
setting properties configure the variable
~org-mobile-force-id-on-agenda-items~ to ~nil~. Org mode then relies
on outline paths, assuming they are unique.
[fn:154] Checksums are stored automatically in the file
[fn:155] Checksums are stored automatically in the file
=checksums.dat=.
[fn:155] The file will be empty after this operation.
[fn:156] The file will be empty after this operation.
[fn:156] https://www.ctan.org/pkg/comment
[fn:157] https://www.ctan.org/pkg/comment
[fn:157] By default this works only for LaTeX, HTML, and Texinfo.
[fn:158] By default this works only for LaTeX, HTML, and Texinfo.
Configure the variable ~orgtbl-radio-table-templates~ to install
templates for other modes.
[fn:158] If the =TBLFM= keyword contains an odd number of dollar
[fn:159] If the =TBLFM= keyword contains an odd number of dollar
characters, this may cause problems with Font Lock in LaTeX mode. As
shown in the example you can fix this by adding an extra line inside
the =comment= environment that is used to balance the dollar
@ -21809,9 +21813,9 @@ expressions. If you are using AUCTeX with the font-latex library,
a much better solution is to add the =comment= environment to the
variable ~LaTeX-verbatim-environments~.
[fn:159] The ~agenda*~ view is the same as ~agenda~ except that it
[fn:160] The ~agenda*~ view is the same as ~agenda~ except that it
only considers /appointments/, i.e., scheduled and deadline items that
have a time specification =[h]h:mm= in their time-stamps.
[fn:160] Note that, for ~org-odd-levels-only~, a level number
[fn:161] Note that, for ~org-odd-levels-only~, a level number
corresponds to order in the hierarchy, not to the number of stars.

View File

@ -251,17 +251,6 @@ and headings will be visually numeroted.
You can turn this on/off on a per-file basis with =#+startup: num= or
=#+startup: nonum=.
*** New option ~org-babel-shell-return-value-is-exit-status~
When set to =t=, consider the return value of a shell source code
block is the exit status of its last command.
The default for this option is =nil=, i.e. the return value of a shell
block is the output of the commands.
You can turn this on individual blocks by setting the header argument
=:value-is-exit-status= to =t=.
** Removed or renamed functions and variables
*** Renamed ~org-columns-set-tags-or-toggle~
@ -323,6 +312,7 @@ Org refile variables and functions have been moved to a new file.
This bug [[https://lists.gnu.org/archive/html/emacs-orgmode/2013-08/msg00072.html][originally reported]] by Matt Lundin and investigated by Andrew
Hyatt has been fixed. Thanks to both of them.
* Version 9.3
** Incompatible changes

View File

@ -71,16 +71,6 @@ outside the Customize interface."
(set-default symbol value)
(org-babel-shell-initialize)))
(defcustom org-babel-shell-return-value-is-exit-status nil
"Should we consider the shell exit status as the return value?
When this is set to nil (the default), consider that the return
value of a shell source block is the output of the commands.
Otherwise, consider the return value to be the exit status of the
last command of the block."
:group 'org-babel
:type 'boolean
:package-version '(Org . "9.4"))
(defun org-babel-execute:shell (body params)
"Execute a block of Shell commands with Babel.
This function is called by `org-babel-execute-src-block'."
@ -89,8 +79,8 @@ This function is called by `org-babel-execute-src-block'."
(stdin (let ((stdin (cdr (assq :stdin params))))
(when stdin (org-babel-sh-var-to-string
(org-babel-ref-resolve stdin)))))
(value-is-exit-status (or (cdr (assq :value-is-exit-status params))
org-babel-shell-return-value-is-exit-status))
(value-is-exit-status
(member "value" (cdr (assq :result-params params))))
(cmdline (cdr (assq :cmdline params)))
(full-body (concat
(org-babel-expand-body:generic
@ -223,8 +213,8 @@ 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* ((shebang (cdr (assq :shebang params)))
(value-is-exit-status (or (cdr (assq :value-is-exit-status params))
org-babel-shell-return-value-is-exit-status))
(value-is-exit-status
(member "value" (cdr (assq :result-params params))))
(results
(cond
((or stdin cmdline) ; external shell script w/STDIN