From: Tim Cross <theophilusx@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Bug or not a bug? dot expansion in ob-shell
Date: Wed, 19 Feb 2020 23:47:28 +1100 [thread overview]
Message-ID: <87h7zmiw0v.fsf@gmail.com> (raw)
In-Reply-To: <875zg2kcy0.fsf@ucl.ac.uk>
I think I agree with Eric here. However, perhaps I don't fully
understand all the details.
Many shell commans, especially those
which mainly perform 'side effects' like echo, return the exit code.
This value is often used in shell scripts as a type of short hand/short
circuit i.e. combined with logic operators.
Question: would it not be import to separate return value from output
value when it comes to shell scripts and noweb type expansion e.g. if I
had a block where the last command does not do any output, but does
return an exit value as the return value, might it not be important to
have that exit value for the next babel block which uses the previous
block?
Something else which may be relevant is to note that bash is not the
only shell and some commands, like echo, will behave differently
depending on the shell. For exmaple, in some shells, echo with no
arguments will just ouput a newline while on other shells, you need to
explicitly request this behaviour with -n switch.
As a general principal, I think the return value and the output value
should be considered to be distinct items and it would be a mistake to
return the output value when it appears the last command does not return
a value. Do what the shell would do - if it returns the exit code then
return that. If the last command really doesn't return anything i.e. hot
even an exit code, return nil (though I think under posix, at the very
least, the exit code is returned).
Fraga, Eric <e.fraga@ucl.ac.uk> writes:
> On Wednesday, 19 Feb 2020 at 12:38, Bastien wrote:
>> "0" is the _exit code_ of the successful echo command, not the value
>> returned by the echo command.
>
> But echo does not "return" the string as a value. It outputs the
> string.
>
> To quote the man page for bash, "the return value of a simple command is
> its status". Further, a function does not actually return any value
> beyond the status of the last command or a value given on a =return=
> statement.
>
>> So In Vladimir's example, both ":results value" and ":results output"
>> should return the same result, i.e. ".".
>
> I disagree. I think the current behaviour (i.e. before your attempt to
> "correct"" this) is correct given the documentation you quoted!
>
>> Was it common to expect the exit code when executing shell code?
>
> Common? I have no idea. *I* did expect this. But that's maybe because
> I do use the shell a lot.
>
> I think there's a clear distinction between value and output for src
> blocks and blurring this distinction for shell src blocks would be
> misleading. The option to request the output as the outcome of the src
> block is already there.
--
Tim Cross
next prev parent reply other threads:[~2020-02-19 12:47 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-19 9:02 Bug or not a bug? dot expansion in ob-shell Vladimir Nikishkin
2020-02-19 9:27 ` Fraga, Eric
2020-02-19 9:41 ` Bastien
2020-02-19 9:43 ` Bastien
2020-02-19 9:57 ` Bastien
2020-02-19 11:03 ` Fraga, Eric
2020-02-19 11:38 ` Bastien
2020-02-19 11:56 ` Fraga, Eric
2020-02-19 12:06 ` Vladimir Nikishkin
2020-02-19 12:10 ` Bastien
2020-02-19 12:27 ` Bastien
2020-02-27 14:25 ` Kaushal Modi
2020-02-19 12:47 ` Tim Cross [this message]
2020-02-19 13:00 ` Bastien
2020-02-19 13:15 ` Tim Cross
2020-02-19 13:23 ` Bastien
2020-02-19 13:31 ` Fraga, Eric
2020-02-19 13:43 ` Bastien
2020-02-19 14:05 ` Fraga, Eric
2020-02-19 16:00 ` Bastien
2020-02-19 19:43 ` Diego Zamboni
2020-02-19 20:41 ` Samuel Wales
2020-02-19 21:32 ` Bastien
2020-02-20 20:37 ` Nick Dokos
2020-02-20 21:01 ` Tim Cross
2020-02-21 6:55 ` Derek Feichtinger
2020-02-21 8:04 ` Bastien
2020-02-21 21:04 ` Nick Dokos
2020-02-22 6:23 ` Jack Kamm
2020-02-22 13:37 ` Bastien
2020-02-23 9:50 ` Stefan Nobis
2020-02-23 13:13 ` Bastien
2020-02-23 16:13 ` Jack Kamm
2020-02-23 20:44 ` Bastien
2020-02-29 15:35 ` Jack Kamm
2020-02-29 15:39 ` Jack Kamm
2020-03-01 2:08 ` Tom Gillespie
2020-03-01 3:50 ` Tim Cross
2020-03-04 18:41 ` Nick Dokos
2020-09-06 17:33 ` Bastien
2020-03-01 4:09 ` Jack Kamm
2020-03-01 5:07 ` Tom Gillespie
2020-03-01 5:58 ` Jack Kamm
2020-03-01 15:46 ` Jack Kamm
2020-09-06 17:36 ` Bastien
2020-09-07 17:39 ` Bastien
2020-02-23 15:27 ` Fraga, Eric
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h7zmiw0v.fsf@gmail.com \
--to=theophilusx@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).