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)