emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Problem with bash arrays from list-valued org-babel :var assignm


From: Neil Jerram
Subject: Re: [O] Problem with bash arrays from list-valued org-babel :var assignments?
Date: Fri, 9 Jun 2017 10:16:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]