Browse Source

ob-sh: customize shell quoting format with org-babel-sh-var-quote-fmt.

* lisp/ob-sh.el (org-babel-sh-var-quote-fmt): Now possible to
  customize the format string used to escape arguments to shell code
  blocks.
Eric Schulte 14 years ago
parent
commit
70d338ec46
1 changed files with 8 additions and 2 deletions
  1. 8 2
      lisp/ob-sh.el

+ 8 - 2
lisp/ob-sh.el

@@ -45,6 +45,12 @@
   "Command used to invoke a shell.
 This will be passed to  `shell-command-on-region'")
 
+(defcustom org-babel-sh-var-quote-fmt
+  "$(cat <<'BABEL_TABLE'\n%s\nBABEL_TABLE\n)"
+  "Format string used to escape variables when passed to shell scripts."
+  :group 'org-babel
+  :type 'string)
+
 (defun org-babel-execute:sh (body params)
   "Execute a block of Shell commands with Babel.
 This function is called by `org-babel-execute-src-block'."
@@ -100,13 +106,13 @@ var of the same value."
                           (if (listp el)
                               (mapcar #'deep-string el)
 			    (org-babel-sh-var-to-sh el sep))))
-	(format "$(cat <<'BABEL_TABLE'\n%s\nBABEL_TABLE\n)"
+	(format org-babel-sh-var-quote-fmt
 		(orgtbl-to-generic
 		 (deep-string (if (listp (car var)) var (list var)))
 		 (list :sep (or sep "\t")))))
     (if (stringp var)
 	(if (string-match "[ \t\n\r]" var)
-	    (format "$(cat <<BABEL_STRING\n%s\nBABEL_STRING\n)" var)
+	    (format org-babel-sh-var-quote-fmt var)
 	  (format "%s" var))
       (format "%S" var))))