emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best practice for writing and debugging shell source blocks?


From: Max Nikulin
Subject: Re: Best practice for writing and debugging shell source blocks?
Date: Thu, 26 Oct 2023 16:56:48 +0700
User-agent: Mozilla Thunderbird

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]