1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

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.
This commit is contained in:
Eric Schulte 2014-06-07 11:14:03 -04:00
parent 4357dde362
commit c3e497f394
3 changed files with 16 additions and 2 deletions

View File

@ -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))
" ")))

View File

@ -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

View File

@ -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)))))