I have an interesting problem that I am sure there must be a simple answer to if I can find the right syntax.
Essentially, as outlined below, I have a simple sh code block that prints a variable that is declared as part of #+begin_src.
#+name: test-fn #+begin_src sh :var testvar="This is a test" echo testvar=$testvar #+end_src #+RESULTS: test-fn : testvar=This is a test #+begin_src sh :noweb yes <<test-fn>> #+end_src #+RESULTS: : testvar=
When I execute the code block directly, the parameter is evaluated. When it is called from a noweb reference in a different code block, the parameter is not evaluated.
How can I get the called code block to evaluate it's parameters?
EDIT1: I am using GNU Emacs 188.8.131.52 (x86_64-w64-mingw32) of 2016-05-26 running on Windows 10
EDIT2: Including the actual problem in detail
#+name: test-harness-running? #+begin_src ruby :results value ... #+end_src #+name: start-fw-test-harness #+begin_src sh :noweb yes :var running=test-harness-running? :results output ... #+end_src #+name: remove-fw-flash #+begin_src sh :results output ... #+end_src #+name: stop-fw-test-harness-if-running #+begin_src sh :var running=test-harness-running? :noweb yes :results output ... #+end_src #+begin_src sh :noweb yes :results output <<stop-fw-test-harness-if-running>> <<remove-fw-flash>> <<start-fw-test-harness>> #+end_src
The reason I've been doing it like this is I re-use stop-fw-test-harness-if-running, remove-fw-flash and start-fw-test-harness in many different scenarios (I used to use command line for it but I find babel gives me greater flexibility).
The problem is that start-fw-test-harness and stop-fw-test harness should only do their thing if the test harness is already started/stopped. However when called from a noweb reference, "running" never gets set as test-harness-running? is not called and so neither of these ever do anything. They work just fine when called directly.
EDIT3: Applying mutbuerger's solution to my problem, I get:
#+begin_src sh :noweb yes :results output :var dummy1=stop-fw-test-harness-if-running :var dummy2=remove-fw-flash :var dummy3=start-fw-test-harness echo $dummy1 echo $dummy2 echo $dummy3 #+end_src #+RESULTS: : nil : 22 Sep 2016 09:50:30 Deleting 351277001993561_STORE.prps 351277001993561_STORE.prps has been deleted : nil
While this clearly works, I am reluctant to Accept the answer on account of the copious use of dummy variables and that I am not 100% sure the order in which the functions are called is clearly defined.
Following mutbuerger's revised solution, this fixes my problem perfectly:
#+begin_src sh :results output :noweb yes <<stop-fw-test-harness-if-running()>> <<remove-fw-flash()>> <<start-fw-test-harness()>> #+end_src