emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* passing string to sh source code block
@ 2019-03-16 12:47 Daniel Herzig
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Herzig @ 2019-03-16 12:47 UTC (permalink / raw)
  To: Orgmode Mailing List

Hi!

I am trying to pass a path to an org-source-codeblock using the :var tag
in the header:

#+BEGIN_SRC sh :var directory="/x/y/z"
cd directory
ls
#+END_SRC

The output of the ls command shows that I obviously stay in the location
of my .org file (not "/x/y/z") -- is there a way to pass the path to the source
codeblock, without having to enter the path inside the block?

Any hint appreciated, thanks in advance,

cheers,
Daniel

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

* Re: passing string to sh source code block
       [not found] <878sxfdlzi.fsf@outlook.at>
@ 2019-03-16 13:07 ` Daniel Herzig
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Herzig @ 2019-03-16 13:07 UTC (permalink / raw)
  To: Orgmode Mailing List

Sorry, I found my mistake. I'll post it anyway, maybe it's of use to
someone.

My path contains spaces, so I had to change the code a bit (see below).

Daniel Herzig <daniel.herzig@outlook.at> writes:

> Hi!
>
> I am trying to pass a path to an org-source-codeblock using the :var tag
> in the header:
>
> #+BEGIN_SRC sh :var directory="/x/y/z"
> cd directory
> ls
> #+END_SRC

#+BEGIN_SRC sh :var directory="/x/y/z"
cd "$directory"
ls                             
#+END_SRC

Like this it works as needed.

> The output of the ls command shows that I obviously stay in the location
> of my .org file (not "/x/y/z") -- is there a way to pass the path to the source
> codeblock, without having to enter the path inside the block?
>
> Any hint appreciated, thanks in advance,
>
> cheers,
> Daniel

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

end of thread, other threads:[~2019-03-16 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-16 12:47 passing string to sh source code block Daniel Herzig
     [not found] <878sxfdlzi.fsf@outlook.at>
2019-03-16 13:07 ` Daniel Herzig

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).