emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Quoting of noweb references and variable noweb function arguments


From: Cody Goodman
Subject: [O] Quoting of noweb references and variable noweb function arguments
Date: Sat, 12 Oct 2019 04:26:18 -0500

I'm having an issue with quoting noweb functions. Since quote is used to signify a variable being passed into the noweb syntax function call I cannot put a quote around theno web function call and end up with invalid bash.

I feel like I had this working at some point and it turned out that :results value smartly handles quoting the values or something. I keep seeming to run into the problem though of needing something like:

echo "<<nowebFunction(var1="variableOfCodeBlock")"

My org mode code complete with examples I hope are easy to understand are at the bottom of this email.

Thanks,

Cody Goodman

* Function that mocks getting json with curl (typically I use restclient blocks though or otherwise mix code blocks of differing languages)
** code
   #+name: get-login-json-mock
   #+begin_src sh :results value :var user="user1" pass="pass1" :noweb yes
   echo "{\"loginToken\": \"hunter2\", \"user\": \"$user\", \"pass\": \"$pass\"}"
   #+end_src
   #+RESULTS: get-login-json-mock
   | loginToken": "hunter2 | user1 | pass1 |
** result: works fine
* pick out value from login json returned with jq
** code
   #+name: get-login-json-value
   #+begin_src sh :noweb yes :var logValUserVar="user2" logValUserPass="pass2" jqExpr="[]keys"
   json=<<get-login-json-mock(user="$logValUserVar",pass="$logValPassVar")>>
   echo $json | jq $jqExpr
   #+end_src

   #+RESULTS: get-login-json-value
   | sh: line 2: hunter2 | : command not found |
** result: sh: line 2: hunter2 | : command not found |
* get login token function using previous functions
** code
   #+name: get-login-token
   #+call: get-login-json-value(logValUserVar="user3",logValUserPass="user3",".loginToken")

   #+RESULTS: get-login-token
** result: nothing, because the previous step fails

reply via email to

[Prev in Thread] Current Thread [Next in Thread]