summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2014-06-07 11:14:03 -0400
committerEric Schulte <schulte.eric@gmail.com>2014-06-07 11:16:55 -0400
commitc3e497f394994cf89dd74087685acc82dc12b91d (patch)
tree955cf94ae1f74d84d5207d293e5e889472648b32
parent4357dde36240525f0f834b76256ec995a94396c4 (diff)
downloadorg-mode-c3e497f394994cf89dd74087685acc82dc12b91d.tar.gz
awk code blocks handle tabular input
Protected by a new unit test. * lisp/ob-awk.el (org-babel-execute:awk): Use the `org-babel-awk-var-to-awk' function instead of a simple format string.
-rw-r--r--lisp/ob-awk.el6
-rw-r--r--testing/examples/ob-awk-test.org7
-rw-r--r--testing/lisp/test-ob-awk.el5
3 files changed, 16 insertions, 2 deletions
diff --git a/lisp/ob-awk.el b/lisp/ob-awk.el
index b3d4e28..6c0fb86 100644
--- a/lisp/ob-awk.el
+++ b/lisp/ob-awk.el
@@ -70,8 +70,10 @@ called by `org-babel-execute-src-block'"
(list org-babel-awk-command
"-f" code-file cmd-line)
(mapcar (lambda (pair)
- (format "-v %s=%s"
- (cadr pair) (cddr pair)))
+ (format "-v %s='%s'"
+ (cadr pair)
+ (org-babel-awk-var-to-awk
+ (cddr pair))))
(org-babel-get-header params :var))
(list in-file))
" ")))
diff --git a/testing/examples/ob-awk-test.org b/testing/examples/ob-awk-test.org
index 9a33bf8..63e070f 100644
--- a/testing/examples/ob-awk-test.org
+++ b/testing/examples/ob-awk-test.org
@@ -31,6 +31,13 @@ Use input file
}
#+end_src
+#+name: awk-table-input
+| a | b | c |
+
+#+begin_src awk :var a=awk-table-input
+ BEGIN{ print a; }
+#+end_src
+
* Input data generators
A code block to generate input stream
#+name: genseq
diff --git a/testing/lisp/test-ob-awk.el b/testing/lisp/test-ob-awk.el
index 3546108..478b6a1 100644
--- a/testing/lisp/test-ob-awk.el
+++ b/testing/lisp/test-ob-awk.el
@@ -41,3 +41,8 @@
(org-babel-next-src-block 3)
(should (= 150 (org-babel-execute-src-block)))))
+(ert-deftest ob-awk/tabular-input ()
+ "Test a code block as an input"
+ (org-test-at-id "9e998b2a-3581-43fe-b26d-07d3c507b86a"
+ (org-babel-next-src-block 4)
+ (should (equal '(("a" "b" "c")) (org-babel-execute-src-block)))))