From: Neil Jerram <neil@ossau.homelinux.net>
To: Keith Amidon <camalot@picnicpark.org>, emacs-orgmode@gnu.org
Subject: Re: Problem with bash arrays from list-valued org-babel :var assignments?
Date: Fri, 9 Jun 2017 10:16:07 +0100 [thread overview]
Message-ID: <60469228-cdec-c756-e215-c52bc90f7196@ossau.homelinux.net> (raw)
In-Reply-To: <1496984194.5909.4.camel@picnicpark.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
next prev parent reply other threads:[~2017-06-09 9:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-09 4:56 Problem with bash arrays from list-valued org-babel :var assignments? Keith Amidon
2017-06-09 9:16 ` Neil Jerram [this message]
2017-06-09 22:53 ` Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60469228-cdec-c756-e215-c52bc90f7196@ossau.homelinux.net \
--to=neil@ossau.homelinux.net \
--cc=camalot@picnicpark.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.