[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug or not a bug? dot expansion in ob-shell
From: |
Bastien |
Subject: |
Re: Bug or not a bug? dot expansion in ob-shell |
Date: |
Wed, 19 Feb 2020 13:10:19 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi Eric,
note that the previous behavior only _seemed_ right by chance: there
is no notion of getting the exit code of the shell command in
ob-shell.el, and returning "0" is just a hazard here, just because
(org-babel--string-to-number ".") returns "0", while it should return
nil.
"Fraga, Eric" <address@hidden> 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.
Then we need to fix ob-shell.el to return the exit code of the last
command when :results is not set or explicitely set to "value". Is
this something you want to look at?
Maybe by adding a "echo $?" instruction at the end of shell blocks
or by wrapping the code into something that returns the result?
I think it will come as a surprise for many users, since the natural
expectation seems to get the "output", disregarding bash notion of a
"return value".
I don't know.
> I disagree. I think the current behaviour (i.e. before your attempt to
> "correct"" this) is correct given the documentation you quoted!
Yes, I see how it seems correct, but this was random...
>> 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 won't release 9.4 until we properly fix this, it's important.
> 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.
Agreed.
> The option to request the output as the outcome of the src block is
> already there.
Yes, agreed again.
If you or someone else can look at ob-shell.el and see what can be
done to get the proper value (in bash's terms) of the last command in
the block, that'd be great.
Thanks!
--
Bastien
- Bug or not a bug? dot expansion in ob-shell, Vladimir Nikishkin, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Fraga, Eric, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Bastien, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Fraga, Eric, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Bastien, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Fraga, Eric, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Vladimir Nikishkin, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell,
Bastien <=
- Re: Bug or not a bug? dot expansion in ob-shell, Bastien, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Kaushal Modi, 2020/02/27
- Re: Bug or not a bug? dot expansion in ob-shell, Tim Cross, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Bastien, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Tim Cross, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Bastien, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Fraga, Eric, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Bastien, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Fraga, Eric, 2020/02/19
- Re: Bug or not a bug? dot expansion in ob-shell, Bastien, 2020/02/19