emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Pascal Fleury <fleury@google.com>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: Achim Gratz <Stromeko@nexgo.de>, emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] ob-shell
Date: Fri, 22 Aug 2014 10:52:38 +0200	[thread overview]
Message-ID: <CACc7+8aMk2a5RpA3qvEeBXR8OVjMrbthJLA3OpxKKKvt38aDFg@mail.gmail.com> (raw)
In-Reply-To: <m2d2c4r00v.fsf@polytechnique.org>


[-- Attachment #1.1: Type: text/plain, Size: 1216 bytes --]

Hello,

I have a little patch (attached) that does check the version of bash, and
uses associative arrays (or doesn't) depending on that version.

The problem now is that the test suite will only work on one platform t a
time, i.e. if there is a bash4 there, it will pass, but if it has bash3, it
will work as intended, but return a different value set. Is there a way to
have platform-dependent tests ?

--Pascal



On Wed, Aug 13, 2014 at 3:29 PM, Alan Schmitt <
alan.schmitt@polytechnique.org> wrote:

> On 2014-08-13 15:20, Pascal Fleury <fleury@google.com> writes:
>
> > Yes, sorry for late reaction (it's holiday season here :-).
>
> Funny, it's holiday season here as well (in Bretagne) ;-)
>
> > This is an issue I introduced with the assoc. arrays, which does not
> > verify if the installed version of bash handles them (from bash4 on).
> > It needs a modification in the setup code that checks the version and
> > only issues assoc. array code when bash supports it. And it so happens
> > that Macs have bash3 installed. Will try to find such a machine and
> > add the test.
>
> Thanks a lot. If I can help, please let me know.
>
> Best,
>
> Alan
>
> --
> OpenPGP Key ID : 040D0A3B4ED2E5C7
>



-- 
--paf

[-- Attachment #1.2: Type: text/html, Size: 1891 bytes --]

[-- Attachment #2: 0001-ob-shell-now-checks-for-the-current-bash-version-bef.patch --]
[-- Type: application/octet-stream, Size: 1555 bytes --]

From d28d82dd88d2e61a2ce08cc69eee02b8213c6252 Mon Sep 17 00:00:00 2001
From: Pascal Fleury <fleury@google.com>
Date: Fri, 22 Aug 2014 10:45:20 +0200
Subject: [PATCH] ob-shell now checks for the current bash version before
 emitting code that uses associative arrays, because bash supports them only
 from version 4 and on, and on some platforms (e.g. MacOSX) the default bash
 is v3.

---
 lisp/ob-shell.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 8c58dfd..27d6de7 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -121,10 +121,15 @@ This function is called by `org-babel-execute-src-block'."
      values
      "\n")))
 
+(defun org-babel-shell-bash-version
+  "Returns the major revision of the current bash running on the system."
+  (car (parse-integer (org-babel-execute:shell "echo ${BASH_VERSINFO[0]}" nil))))
+
 (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))))
+   (if (listp values)
+      (if (and (< 3 (org-babel-shell-bash-version) ; bash supports assoc arrays only from version 4 on.
+	       (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)))
-- 
1.9.3


  reply	other threads:[~2014-08-22  8:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 10:03 2 Org tests failing Sebastien Vauban
2014-05-22 10:48 ` Bastien
     [not found]   ` <87tx8iks22.fsf-E3UqQZAQFPqWIDz0JBNUog@public.gmane.org>
2014-06-18 14:55     ` Sebastien Vauban
2014-06-18 21:49       ` Achim Gratz
2014-06-19  8:36         ` Sebastien Vauban
2014-06-19  9:04           ` Sebastien Vauban
2014-06-19  9:08             ` Sebastien Vauban
2014-06-19 20:05           ` Achim Gratz
2014-06-22  8:35             ` [PATCH] ob-shell (was: 2 Org tests failing) Achim Gratz
2014-06-22 12:50               ` [PATCH] ob-shell Eric Schulte
2014-06-23  6:26                 ` Pascal Fleury
2014-06-23 17:20                   ` Achim Gratz
2014-06-23 20:02                 ` Achim Gratz
2014-07-24  7:38                 ` Alan Schmitt
2014-08-04 11:56                   ` Eric Schulte
2014-08-04 19:48                   ` Achim Gratz
2014-08-13 13:12                     ` Alan Schmitt
2014-08-13 13:20                       ` Pascal Fleury
2014-08-13 13:29                         ` Alan Schmitt
2014-08-22  8:52                           ` Pascal Fleury [this message]
2014-08-22 13:08                             ` Pascal Fleury
2014-08-22 18:16                               ` Achim Gratz
2015-01-21 22:58                                 ` Pascal Fleury
2015-01-25 11:41                                   ` Achim Gratz

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACc7+8aMk2a5RpA3qvEeBXR8OVjMrbthJLA3OpxKKKvt38aDFg@mail.gmail.com \
    --to=fleury@google.com \
    --cc=Stromeko@nexgo.de \
    --cc=alan.schmitt@polytechnique.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).