emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Konrad Herbst <k.herbst@stud.uni-heidelberg.de>
To: emacs-orgmode@gnu.org
Subject: Bug: one column table to array conversion in bash
Date: Sun, 27 Sep 2015 17:52:48 +0200	[thread overview]
Message-ID: <560810D0.2040000@stud.uni-heidelberg.de> (raw)

Hello,

Recently I tried to use org-babel for bash with its feature for 
conversation of tables to arrays. I found that a one column table is 
associated with an array in bash while one column of a table retrieved 
by indexing throws the error '(wrong-type-argument listp "foo")'.

Here is an example in org:
-----------Begin-------------------
* Example 1 -- WORKS
#+NAME: table1
| foo  |
| bar  |
| test |

#+BEGIN_SRC bash :var table=table1 :results scalar
echo ${table[0]}
#+END_SRC

#+RESULTS:
: foo

* Example 2 -- DOESN'T WORK
#+NAME: table2
| foo  | one   |
| bar  | two   |
| test | three |

#+BEGIN_SRC bash :var table=table2[,0] :results scalar
echo ${table[1]}
#+END_SRC

#+RESULTS:
:

* Example 3 -- WORKS
#+BEGIN_SRC bash :var table=table2[,0:-1] :results scalar
echo ${table['bar']}
#+END_SRC

#+RESULTS:
: two
---------End-----------------

This was kind of counterintuitive to me but is that maybe the wanted 
behavior? I think it has something to do with that the function 
'org-babel-variable-assignments:bash_array' in ob-shell.el is called for 
the first example, while 'org-babel-variable-assignments:bash_assoc' is 
incorrectly called for the second. Thats why the third example is 
working again.

In the end I drilled it down to this function:
'org-babel-ref-resolve' in ob-ref.el. The first example evaluates to a 
list of lists while the second only to a list. Shouldn't both give the 
same result?

Sorry, but would you say thats a bug or a feature request?

Best,
Konrad

Emacs  : GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll 
bars)
  of 2015-06-28 on trouble, modified by Debian
Package: Org-mode version 8.3.1 (release_8.3.1-280-g6f2579)

                 reply	other threads:[~2015-09-27 15:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=560810D0.2040000@stud.uni-heidelberg.de \
    --to=k.herbst@stud.uni-heidelberg.de \
    --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).