hi. i just wandered down a rathole others could avoid. the following program fails in (what was to me) a mysterious way: ---- #+BEGIN_SRC awk :var a=2 BEGIN{print $a;} #+END_SRC ----
it turns out values for variables to awk need to be strings (rather than a number, as above). below is a patch to give what might be a less mysterious error message. also: for an awk invocation with ":var a=b", all occurrences of "$a" in the body of the awk code are changed to "b". i'm curious why this is done rather than invoking awk with "-v a=b"? or, moving the initialization into a "BEGIN{}" block? maybe because of the variety of awk variants loose in the world? cheers, Greg ---- diff --git a/lisp/ob-awk.el b/lisp/ob-awk.el index ed98afd..162ddfb 100644 --- a/lisp/ob-awk.el +++ b/lisp/ob-awk.el @@ -47,6 +47,8 @@ (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))) + (if (not (stringp (cdr pair))) + (error "awk variable values must be strings")) (setf body (replace-regexp-in-string (regexp-quote (format "$%s" (car pair))) (cdr pair) body))) body)