From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cody Goodman Subject: Quoting of noweb references and variable noweb function arguments Date: Sat, 12 Oct 2019 04:26:18 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c1bda10594b33a78" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:59447) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJDfU-0007p5-Jf for emacs-orgmode@gnu.org; Sat, 12 Oct 2019 05:26:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJDfT-000456-C7 for emacs-orgmode@gnu.org; Sat, 12 Oct 2019 05:26:32 -0400 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:38183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJDfT-00044Y-5T for emacs-orgmode@gnu.org; Sat, 12 Oct 2019 05:26:31 -0400 Received: by mail-qk1-x72f.google.com with SMTP id x4so7281544qkx.5 for ; Sat, 12 Oct 2019 02:26:30 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --000000000000c1bda10594b33a78 Content-Type: text/plain; charset="UTF-8" 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 "<> 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 --000000000000c1bda10594b33a78 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'm having an issue with quoting noweb functions. Sinc= e quote is used to signify a variable being passed into the noweb syntax fu= nction 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 som= ething. I keep seeming to run into the problem though of needing something = like:

echo "<<nowebFunction(var1=3D"variableOfCodeBl= ock")"

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

Thanks,

C= ody Goodman

* Function that mocks getting json with curl (typically = I use restclient blocks though or otherwise mix code blocks of differing la= nguages)
** code
=C2=A0 =C2=A0#+name: get-login-json-mock
=C2=A0 = =C2=A0#+begin_src sh :results value :var user=3D"user1" pass=3D&q= uot;pass1" :noweb yes
=C2=A0 =C2=A0echo "{\"loginToken\&q= uot;: \"hunter2\", \"user\": \"$user\", \&quo= t;pass\": \"$pass\"}"
=C2=A0 =C2=A0#+end_src
=C2= =A0 =C2=A0#+RESULTS: get-login-json-mock
=C2=A0 =C2=A0| loginToken"= : "hunter2 | user1 | pass1 |
** result: works fine
* pick out va= lue from login json returned with jq
** code
=C2=A0 =C2=A0#+name: ge= t-login-json-value
=C2=A0 =C2=A0#+begin_src sh :noweb yes :var logValUse= rVar=3D"user2" logValUserPass=3D"pass2" jqExpr=3D"= []keys"
=C2=A0 =C2=A0json=3D<<get-login-json-mock(user=3D&quo= t;$logValUserVar",pass=3D"$logValPassVar")>>
=C2=A0= =C2=A0echo $json | jq $jqExpr
=C2=A0 =C2=A0#+end_src

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

=C2=A0 =C2=A0#+RESULTS: get-login-token** result: nothing, because the previous step fails
--000000000000c1bda10594b33a78--