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

