From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Jerram Subject: Re: Problem with bash arrays from list-valued org-babel :var assignments? Date: Fri, 9 Jun 2017 10:16:07 +0100 Message-ID: <60469228-cdec-c756-e215-c52bc90f7196@ossau.homelinux.net> References: <1496984194.5909.4.camel@picnicpark.org> 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]:60491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJG1h-00026g-E3 for emacs-orgmode@gnu.org; Fri, 09 Jun 2017 05:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJG1e-0003G7-A0 for emacs-orgmode@gnu.org; Fri, 09 Jun 2017 05:16:17 -0400 Received: from smtp-out-5.talktalk.net ([62.24.135.69]:24774) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJG1e-0003FW-2i for emacs-orgmode@gnu.org; Fri, 09 Jun 2017 05:16:14 -0400 In-Reply-To: <1496984194.5909.4.camel@picnicpark.org> Content-Language: en-US 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" To: Keith Amidon , emacs-orgmode@gnu.org On 09/06/17 05:56, Keith Amidon wrote: > With current org-mode, when I try to execute the following org-babel > block: > > #+begin_src bash :var lst='(1 2 3 4 5 6 7) > printf "%s\n" "${lst[*]}" > #+end_src > > I get result and the following error in the minibuffer: > > Wrong type argument: listp, 1 > > This, on the other hand works fine: > > #+begin_src emacs-lisp :var lst='(1 2 3 4 5 6 7) > lst > #+end_src > > In investigating this, I looked into the code for how bash variables > are set from the org variables and found this code in ob-shell that I > don't really understand: > > (defun org-babel--variable-assignments:bash (varname values &optional sep hline) > "Represents the parameters as useful Bash shell variables." > (if (listp values) > (if (and (listp (car values)) (= 1 (length (car values)))) > (org-babel--variable-assignments:bash_array varname values sep hline) > (org-babel--variable-assignments:bash_assoc varname values sep hline)) > (org-babel--variable-assignments:sh-generic varname values sep hline))) Based on that code, I'd expect this to work, and it does: #+begin_src bash :var lst='((1) (2) (3) (4) (5) (6) (7)) printf "%s\n" "${lst[*]}" #+end_src #+RESULTS: : 1 2 3 4 5 6 7 But I agree that it would still be nice if the more intuitive form that you mentioned also worked. Regards, Neil