all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Quoting of noweb references and variable noweb function arguments
@ 2019-10-12  9:26 Cody Goodman
  2022-10-19  9:04 ` [O] " Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Cody Goodman @ 2019-10-12  9:26 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2159 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [O] Quoting of noweb references and variable noweb function arguments
  2019-10-12  9:26 Quoting of noweb references and variable noweb function arguments Cody Goodman
@ 2022-10-19  9:04 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-10-19  9:04 UTC (permalink / raw)
  To: Cody Goodman; +Cc: emacs-orgmode

Cody Goodman <codygman.consulting@gmail.com> writes:

> 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.
>    #+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

You cannot pass src block variables to noweb. It is currently not supported.

And you cannot pass bash bindings to noweb. Noweb expansion happens
before executing the bash code. It is not possible to know that bash
assignments at that point.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-19  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-12  9:26 Quoting of noweb references and variable noweb function arguments Cody Goodman
2022-10-19  9:04 ` [O] " Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.