I first define
#+NAME: 01H7T457WEWS07WD5T05BS5CN9
#+begin_src shell :results verbatim replace drawer :wrap src json
echo "foo"
#+end_src
#+RESULTS: 01H7T457WEWS07WD5T05BS5CN9
#+begin_src json
foo
#+end_src
..and run it
#+begin_src shell :var _01H7STDXTTPR3GVA6ZJFCBJTWD=01H7T457WEWS07WD5T05BS5CN9 :results verbatim :noweb yes
curl -v 'https://gnu.org/test' \
-H "Content-Type: application/json" \
-H 'Authorization: Bearer '$_01H7STDXTTPR3GVA6ZJFCBJTWD''
#+end_src
, and I get
curl: (3) URL rejected: No host part in the URL
However, if I define within, it works fine.
#+begin_src shell :results verbatim
export _01H7T457WEWS07WD5T05BS5CN9="foo"
curl -v 'https://gnu.org/test' \
-H "Content-Type: application/json" \
-H 'Authorization: Bearer '$_01H7T457WEWS07WD5T05BS5CN9''
#+end_src
I'm not really sure what's happening here;) Am I typing it wrong?
#+RESULTS: : <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> : <html><head> : <title>301 Moved Permanently</title> : </head><body> : <h1>Moved Permanently</h1> : <p>The document has moved <a href="https://www.gnu.org/test">here</a>.</p> : <hr> : <address>Apache/2.4.29 Server at gnu.org Port 443</address> : </body></html>
-v
which obscured the error output. The first one does indeed fail (with a different message:curl: (3) URL using bad/illegal format or missing URL
) but that's because the value of the env variable includes a trailing newline. DoC-c C-v C-v
on each code block to see what it expands to and cut and paste that into a terminal to debug.echo -n "foo"
in the first code block.