From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Herbst Subject: Bug: one column table to array conversion in bash Date: Sun, 27 Sep 2015 17:52:48 +0200 Message-ID: <560810D0.2040000@stud.uni-heidelberg.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgEG7-0003az-Bk for emacs-orgmode@gnu.org; Sun, 27 Sep 2015 11:53:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgEG3-0004UX-AW for emacs-orgmode@gnu.org; Sun, 27 Sep 2015 11:53:03 -0400 Received: from relay2.uni-heidelberg.de ([129.206.119.212]:46388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgEG3-0004TM-1G for emacs-orgmode@gnu.org; Sun, 27 Sep 2015 11:52:59 -0400 Received: from ix.urz.uni-heidelberg.de (cyrus-portal01.urz.uni-heidelberg.de [129.206.100.176]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t8RFqse4025921 for ; Sun, 27 Sep 2015 17:52:54 +0200 Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (Postfix) with ESMTPS id 25FA121CD0E6 for ; Sun, 27 Sep 2015 17:52:54 +0200 (CEST) Received: from [192.168.2.189] (dslb-094-217-097-004.094.217.pools.vodafone-ip.de [94.217.97.4]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id t8RFqrB4002127 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Sun, 27 Sep 2015 17:52:54 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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)