Changes
[emacs.git] / .emacs.d / elisp / org / ob-awk.el
index ed98afd..a96ba1a 100644 (file)
@@ -46,9 +46,6 @@
 
 (defun org-babel-expand-body:awk (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (dolist (pair (mapcar #'cdr (org-babel-get-header params :var)))
-    (setf body (replace-regexp-in-string
-                (regexp-quote (format "$%s" (car pair))) (cdr pair) body)))
   body)
 
 (defun org-babel-execute:awk (body params)
@@ -68,10 +65,17 @@ called by `org-babel-execute-src-block'"
                       (with-temp-file tmp
                         (insert (org-babel-awk-var-to-awk res)))
                       tmp))))
-         (cmd (mapconcat #'identity (remove nil (list org-babel-awk-command
-                                                     "-f" code-file
-                                                     cmd-line
-                                                     in-file))
+         (cmd (mapconcat #'identity
+                        (append
+                         (list org-babel-awk-command
+                               "-f" code-file cmd-line)
+                         (mapcar (lambda (pair)
+                                   (format "-v %s='%s'"
+                                           (cadr pair)
+                                           (org-babel-awk-var-to-awk
+                                            (cddr pair))))
+                                 (org-babel-get-header params :var))
+                         (list in-file))
                         " ")))
     (org-babel-reassemble-table
      (let ((results
@@ -101,11 +105,6 @@ called by `org-babel-execute-src-block'"
       (mapconcat echo-var var "\n"))
      (t (funcall echo-var var)))))
 
-(defun org-babel-awk-table-or-string (results)
-  "If the results look like a table, then convert them into an
-Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-script-escape results))
-
 (provide 'ob-awk)