From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Kettleborough Subject: Re: ob-shell: using a table variable with bash Date: Wed, 8 Mar 2017 11:27:44 +0000 Message-ID: <7e7ce312-15c3-6340-eb30-1ad046d1eabf@earlham.ac.uk> References: <1811afdb-ffe4-37e7-9858-19b22d7ff2ed@earlham.ac.uk> <8737eo2n29.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------148A1381DFDC92AC5D703759" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cligR-0008DH-Sx for emacs-orgmode@gnu.org; Wed, 08 Mar 2017 15:59:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cligN-0006Ht-1n for emacs-orgmode@gnu.org; Wed, 08 Mar 2017 15:59:43 -0500 Received: from mail-db5eur01on0107.outbound.protection.outlook.com ([104.47.2.107]:48304 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cligM-0006HK-J9 for emacs-orgmode@gnu.org; Wed, 08 Mar 2017 15:59:38 -0500 In-Reply-To: <8737eo2n29.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org --------------148A1381DFDC92AC5D703759 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit On 08/03/17 08:24, Nicolas Goaziou wrote: > I have no objection to this patch, but I think it needs to be > documented, if only as a code comment. IIRC, there is also some > documentation about "ob-shell" on Worg. It would be nice to document > this feature. I can't actually find any documentation for ob-shell. I had to read the source code. I have documented it as a code comment in my patch (with proper commit message). Thanks, George. --------------148A1381DFDC92AC5D703759 Content-Type: text/x-patch; name="0001-ob-shell-use-old-table-var-behaviour-when-sep-is-use.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-ob-shell-use-old-table-var-behaviour-when-sep-is-use.pa"; filename*1="tch" >From 97dadaf0ba0f18772d4d8ac968ea63374937b179 Mon Sep 17 00:00:00 2001 From: George Kettleborough Date: Wed, 8 Mar 2017 11:25:37 +0000 Subject: [PATCH] ob-shell: use old table var behaviour when sep is used When using the bash shell and an org table is used as a variable, the default behaviour is to declare it as a bash array. The generic behaviour is to convert the table to a string with columns separated by a given separator string. This allows a user to choose the generic behaviour by declaring the separator using a :separator option to the code block. --- lisp/ob-shell.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el index 9c22af8..8c7b4f1 100644 --- a/lisp/ob-shell.el +++ b/lisp/ob-shell.el @@ -140,7 +140,9 @@ This function is called by `org-babel-execute-src-block'." (defun org-babel--variable-assignments:bash (varname values &optional sep hline) "Represents the parameters as useful Bash shell variables." - (if (listp values) + ;; we declare org tables as bash array types, unless the user has + ;; set the :separator option + (if (and (listp values) (null sep)) (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)) -- 2.10.1.502.g6598894 --------------148A1381DFDC92AC5D703759--