all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Matt <matt@excalamus.com>
To: "\"Rudolf Adamkovič\"" <salutis@me.com>
Cc: "ihor radchenko" <yantar92@posteo.net>,
	"emacs-orgmode" <emacs-orgmode@gnu.org>
Subject: Re: Bash results broken?
Date: Mon, 19 Dec 2022 22:40:53 -0500	[thread overview]
Message-ID: <1852d9eb52f.c4c534f9581400.7140516675874523594@excalamus.com> (raw)
In-Reply-To: <m2r0wu29b7.fsf@me.com>


 ---- On Mon, 19 Dec 2022 19:44:12 -0500  Rudolf Adamkovič  wrote --- 
 > Ihor Radchenko yantar92@posteo.net> writes:
 > 
 > > Fixed on bugfix.
 > 
 > I can confirm that the fix works.  Thank you!

I can confirm it works, too, for the 1 2 3 example.  However, it puts double quotes around text:

#+BEGIN_SRC sh :results list
echo hello
echo world
echo !
#+END_SRC

#+RESULTS:
- "hello"
- "world"
- "!"

I was working on other ob-shell related stuff and my Emacs got into a mixed state where =ob-shell/results-list= was defined, but the fix wasn't (or wasn't loaded).  I fixed the failing test before I saw this thread and Ihor's fix.  The way I solved it was to wrap either =org-babel-import-elisp-from-file= or =org-babel-sh-evaluate= like,

(mapcar #'car (org-babel-import-elisp-from-file tmp-file))

or 

(mapcar #'car  (org-babel-sh-evaluate session full-body params stdin cmdline))

Doing this (without Ihor's fix in place) returns:

#+BEGIN_SRC sh :results list
echo "hello"
echo "world"
echo "!"
#+END_SRC

#+RESULTS:
- hello
- world
- !

The underlying issue, so far as I understand it, is that =org-babel-import-elisp-from-file= returns a list-of-lists.  For example, ((1) (2) (3)) or (("hello") ("world") ("!")).  I thought it appropriate to flatten it out to (1 2 3) or ("hello" "world" "!").

Independently from how I addressed the bug, I feel it raises an important question: how should :results list handle text/strings? 

I'm not sure which approach is more "appropriate".   If I echo a string without quotes, as I did in the first example, should it return a list that's got quotes?  The hello world example is a little contrived–it's good practice to use double-quotes.  I think a more realistic use case would be listing a directory.  In that case, I'd probably want the list of items to be unquoted:

Original:

#+BEGIN_SRC sh :results list
ls /home/ahab/.emacs.d/straight/repos/org/testing/lisp/ | head -n 3
#+END_SRC

#+RESULTS:
- ("test-ob-awk.el")
- ("test-ob-C.el")
- ("test-ob-clojure.el")

Ihor solution:

#+BEGIN_SRC sh :results list
ls /home/ahab/.emacs.d/straight/repos/org/testing/lisp/ | head -n 3
#+END_SRC

#+RESULTS:
- "test-ob-awk.el"
- "test-ob-C.el"
- "test-ob-clojure.el"

MAPCAR solution:

#+BEGIN_SRC sh :results list
ls /home/ahab/.emacs.d/straight/repos/org/testing/lisp/ | head -n 3
#+END_SRC

#+RESULTS:
- test-ob-awk.el
- test-ob-C.el
- test-ob-clojure.el

For :results list, the manual says, "Interpret the results as an Org list.  If the result is a single value, create a list of one element".  I don't find that clarifies what would be best.

Thoughts?




  reply	other threads:[~2022-12-20  3:41 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 16:22 Bash results broken? Rudolf Adamkovič
2022-12-16 17:41 ` Ihor Radchenko
2022-12-18 11:19   ` Ihor Radchenko
2022-12-20  0:44     ` Rudolf Adamkovič
2022-12-20  3:40       ` Matt [this message]
2022-12-25 11:23         ` Ihor Radchenko
2022-12-26  2:25           ` Matt
2022-12-26  9:26             ` Ihor Radchenko
2022-12-21  6:17   ` ob-shell intentions and paperwork (was Bash results broken?) Matt
2022-12-27 20:48     ` Matt
2022-12-29 11:08       ` Ihor Radchenko
2022-12-29 14:20         ` Bastien Guerry
2022-12-30  5:34         ` Matt
2022-12-30  8:06           ` Bastien Guerry
2022-12-30 18:46           ` Matt
2022-12-31 14:31             ` Ihor Radchenko
2023-01-01 23:55               ` Matt
2023-01-02  9:47                 ` Ihor Radchenko
2023-01-02 16:40                   ` Matt
2023-01-03 10:50                     ` Ihor Radchenko
2023-01-03 13:00                       ` Matt
2023-01-05 10:31                         ` Ihor Radchenko
2023-01-05 11:21                           ` Bastien Guerry
2023-01-10  2:31                             ` Matt
2023-01-11 11:53                               ` Ihor Radchenko
2023-01-11 16:18                                 ` Matt
2023-01-11 17:02                                   ` Ihor Radchenko
2023-01-11 19:34                                     ` Matt
2023-01-12  8:26                                       ` Ihor Radchenko
2023-01-12 14:43                                     ` Max Nikulin
2023-01-13  9:36                                       ` Ihor Radchenko
2023-01-13 15:18                                         ` Matt
2023-01-13 15:23                                           ` Ihor Radchenko
2023-01-14  7:41                                             ` Max Nikulin
2023-01-14 10:35                                               ` Ihor Radchenko
2023-01-14 15:09                                                 ` cgit and merge commit Max Nikulin
2023-01-24 20:16                                                   ` Ihor Radchenko
2022-12-31 12:56           ` ob-shell intentions and paperwork (was Bash results broken?) Ihor Radchenko
2023-01-02  4:40             ` Refactor org-babel-shell-initialize? (was Re: ob-shell intentions and paperwork (was Bash results broken?)) Matt
2023-01-03  9:29               ` Ihor Radchenko
2023-01-05  8:32                 ` Ihor Radchenko

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1852d9eb52f.c4c534f9581400.7140516675874523594@excalamus.com \
    --to=matt@excalamus.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=salutis@me.com \
    --cc=yantar92@posteo.net \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.