emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: one column table to array conversion in bash
@ 2015-09-27 15:52 Konrad Herbst
  0 siblings, 0 replies; only message in thread
From: Konrad Herbst @ 2015-09-27 15:52 UTC (permalink / raw)
  To: emacs-orgmode

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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-09-27 15:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-27 15:52 Bug: one column table to array conversion in bash Konrad Herbst

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).