all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Org source block header argument :var does not support space separated string
@ 2018-10-20  9:05 stardiviner
  2018-10-20 20:17 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: stardiviner @ 2018-10-20  9:05 UTC (permalink / raw)
  To: org-mode


Org source block header argument :var does not support quoted string with space separator like bellowing example:

For example

**** encrypt text -- ~<<< [TEXT]~

#+NAME: base64 encrypt text
#+begin_src sh
base64 <<< "stardiviner <numbchild@gmail.com>"
#+end_src

#+RESULTS: base64 encrypt text
: c3RhcmRpdmluZXIgPG51bWJjaGlsZEBnbWFpbC5jb20+Cg==

**** decrypt text -- ~-d~

#+begin_src sh :var encrypted="base64 encrypt text"
# base64 -d <<< c3RhcmRpdmluZXIgPG51bWJjaGlsZEBnbWFpbC5jb20+Cg==
base64 -d <<< $encrypted
#+end_src

If I use #+NAME: base64-encrypt-text and :var encrypted=base64-encrypt-text, then it works fine.

-- 
[ stardiviner ] don't need to convince with trends.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

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

* Re: Org source block header argument :var does not support space separated string
  2018-10-20  9:05 Org source block header argument :var does not support space separated string stardiviner
@ 2018-10-20 20:17 ` Nicolas Goaziou
  2018-10-22  0:48   ` stardiviner
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2018-10-20 20:17 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> Org source block header argument :var does not support quoted string with space separator like bellowing example:
>
> For example
>
> **** encrypt text -- ~<<< [TEXT]~
>
> #+NAME: base64 encrypt text
> #+begin_src sh
>
> base64 <<< "stardiviner <numbchild@gmail.com>" #+end_src
>
> #+RESULTS: base64 encrypt text
> : c3RhcmRpdmluZXIgPG51bWJjaGlsZEBnbWFpbC5jb20+Cg==
>
>
> **** decrypt text -- ~-d~
>
> #+begin_src sh :var encrypted="base64 encrypt text"
> # base64 -d <<< c3RhcmRpdmluZXIgPG51bWJjaGlsZEBnbWFpbC5jb20+Cg==
> base64 -d <<< $encrypted
> #+end_src
>
> If I use #+NAME: base64-encrypt-text and :var
> encrypted=base64-encrypt-text, then it works fine.

I cannot reproduce your issues, literally. It complains about
a redirection error or something.

Anyway, I tried the following block:

    #+begin_src emacs-lisp :var encrypted="base64 encrypt text"
    encrypted
    #+end_src

and the output is

    #+results:
    : base64 encrypt text

which means there doesn't seem to be a problem with strings within
quotes.

Regards,

-- 
Nicolas Goaziou

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

* Re: Org source block header argument :var does not support space separated string
  2018-10-20 20:17 ` Nicolas Goaziou
@ 2018-10-22  0:48   ` stardiviner
  2018-10-22 16:04     ` Berry, Charles
  0 siblings, 1 reply; 5+ messages in thread
From: stardiviner @ 2018-10-22  0:48 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Anyway, I tried the following block:
>
>     #+begin_src emacs-lisp :var encrypted="base64 encrypt text"
>     encrypted
>     #+end_src
>
> and the output is
>
>     #+results:
>     : base64 encrypt text
>
> which means there doesn't seem to be a problem with strings within
> quotes.
>
> Regards,

Oops, I misunderstand the :var variable="literal quoted string".
I want to reference the named source's result in variable.

Like:

**** encrypt text -- ~<<< [TEXT]~

#+NAME: base64 encrypt text
#+begin_src sh
base64 <<< "stardiviner <numbchild@gmail.com>"
#+end_src

#+RESULTS: base64 encrypt text
: c3RhcmRpdmluZXIgPG51bWJjaGlsZEBnbWFpbC5jb20+Cg==

**** decrypt text -- ~-d~

#+begin_src sh :var encrypted=<base64 encrypt text>
# base64 -d <<< c3RhcmRpdmluZXIgPG51bWJjaGlsZEBnbWFpbC5jb20+Cg==
# base64 -d <<< $encrypted
echo $encrypted
#+end_src

#+RESULTS[<2018-10-20 16:46:10> 6e5d3875d0928eb95ec1356661f965bdf4882244]:

I can use #+NAME: base64-encrypt-text for first source block, and :var encrypted=base64-encrypt-text for second source block. So it can work. But is it possible to allow space in source block name and make it still can be referenced? Like quote it with <> around the name as my upper example?

-- 
[ stardiviner ] don't need to convince with trends.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

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

* Re: Org source block header argument :var does not support space separated string
  2018-10-22  0:48   ` stardiviner
@ 2018-10-22 16:04     ` Berry, Charles
  2018-10-23 11:39       ` stardiviner
  0 siblings, 1 reply; 5+ messages in thread
From: Berry, Charles @ 2018-10-22 16:04 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode, Nicolas Goaziou



> On Oct 21, 2018, at 5:48 PM, stardiviner <numbchild@gmail.com> wrote:
> 
> Oops, I misunderstand the :var variable="literal quoted string".
> I want to reference the named source's result in variable.
> 
> Like:
> 
> **** encrypt text -- ~<<< [TEXT]~
> 
> #+NAME: base64 encrypt text
> #+begin_src sh
> base64 <<< "stardiviner <numbchild@gmail.com>"
> #+end_src
> 
> #+RESULTS: base64 encrypt text
> : c3RhcmRpdmluZXIgPG51bWJjaGlsZEBnbWFpbC5jb20+Cg==
> 
> **** decrypt text -- ~-d~
> 
> #+begin_src sh :var encrypted=<base64 encrypt text>
> # base64 -d <<< c3RhcmRpdmluZXIgPG51bWJjaGlsZEBnbWFpbC5jb20+Cg==
> # base64 -d <<< $encrypted
> echo $encrypted
> #+end_src


This works 

#+begin_src sh :var encrypted=(org-babel-ref-resolve "base64 encrypt text()")
echo $encrypted
#+end_src

You might write a wrapper, so something like (quote-ref "base64 encrypt text")	will handle it.

HTH,

Chuck

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

* Re: Org source block header argument :var does not support space separated string
  2018-10-22 16:04     ` Berry, Charles
@ 2018-10-23 11:39       ` stardiviner
  0 siblings, 0 replies; 5+ messages in thread
From: stardiviner @ 2018-10-23 11:39 UTC (permalink / raw)
  To: Berry, Charles; +Cc: org-mode, Nicolas Goaziou




Berry, Charles <ccberry@ucsd.edu> writes:
>
> This works 
>
> #+begin_src sh :var encrypted=(org-babel-ref-resolve "base64 encrypt text()")
> echo $encrypted
> #+end_src
>
> You might write a wrapper, so something like (quote-ref "base64 encrypt text")	will handle it.
>

Thanks very much! this solved my problem.

-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

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

end of thread, other threads:[~2018-10-23 11:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-20  9:05 Org source block header argument :var does not support space separated string stardiviner
2018-10-20 20:17 ` Nicolas Goaziou
2018-10-22  0:48   ` stardiviner
2018-10-22 16:04     ` Berry, Charles
2018-10-23 11:39       ` stardiviner

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.