From: Max Nikulin <manikulin@gmail.com>
To: Tim Landscheidt <tim@tim-landscheidt.de>, emacs-orgmode@gnu.org
Subject: Re: Best practice for writing and debugging shell source blocks?
Date: Thu, 26 Oct 2023 16:56:48 +0700 [thread overview]
Message-ID: <d9e1e7f6-134c-42cd-b65f-a6627e079d8d@gmail.com> (raw)
In-Reply-To: <87pm14qddz.fsf@vagabond.tim-landscheidt.de>
On 24/10/2023 21:54, Tim Landscheidt wrote:
> The same thing happens if I add ":session my-test" to all source blocks,
Have you tried to combine variables and session?
#+name: get-random-value
#+begin_src bash
echo "$RANDOM"
#+end_src
#+header: :var random_var=get-random-value
#+begin_src sh :session *sh-with-random*
echo "$random_var + 10"
#+end_src
#+RESULTS:
: 19545 + 10
#+begin_src sh :session *sh-with-random*
echo "$random_var + 20"
#+end_src
#+RESULTS:
: 19545 + 20
#+begin_src sh :session *sh-with-random*
echo "$random_var + 30"
#+end_src
#+RESULTS:
: 19545 + 30
Or with noweb reference
#+begin_src sh :noweb-ref use-random
echo "$random_var + 10"
#+end_src
#+begin_src sh :noweb-ref use-random
echo "$random_var + 20"
#+end_src
#+begin_src sh :noweb-ref use-random
echo "$random_var + 30"
#+end_src
#+begin_src sh :var random_var=get-random-value :noweb yes
<<use-random>>
#+end_src
P.S. For the case that you have not seen it, the following page contains
some examples:
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-shell.html
prev parent reply other threads:[~2023-10-26 9:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 14:54 Best practice for writing and debugging shell source blocks? Tim Landscheidt
2023-10-26 9:56 ` Max Nikulin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9e1e7f6-134c-42cd-b65f-a6627e079d8d@gmail.com \
--to=manikulin@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=tim@tim-landscheidt.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).