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