[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ob-shell: async support in "shell" vs "bash"
From: |
Matt |
Subject: |
Re: ob-shell: async support in "shell" vs "bash" |
Date: |
Sun, 16 Jun 2024 20:32:01 +0200 |
User-agent: |
Zoho Mail |
---- On Mon, 10 Jun 2024 04:33:26 +0200 Suhail Singh wrote ---
> On my system both "shell" and "bash" language blocks use "bash"
> However, the value of org-babel-header-args:lang differs:
>
> #+begin_src emacs-lisp :results value replace verbatim
> org-babel-header-args:shell
> #+end_src
>
> #+RESULTS:
> : ((async (yes no)))
>
> #+begin_src emacs-lisp :results value replace verbatim
> org-babel-header-args:bash
> #+end_src
>
> #+RESULTS:
> : nil
>
> Is this a bug, or are async blocks only currently allowed in "shell"
> language blocks and not "bash" language blocks?
Thank you for your message!
:async should work for all shell types. Are you finding that it's not?
In practice, anything but a "no" or "none" for :async should work (see
"org-babel-comint-use-async"). For example, the following should run the block
asynchronously:
#+begin_src bash :session *my-bash* :async banana
echo "hi"
sleep 3
echo "bye"
#+end_src
All shell languages use the "explicit-shell-file-name" to define a comint
buffer using the "shell" command. For "shell" blocks, Babel uses whatever the
user has set for "explicit-shell-file-name", most likely "shell-file-name"
which defaults to /bin/sh. Many systems symlink /bin/sh to bash for
interactive shells. I suspect this is what's happening on your system. You
can check this with something like 'ls -la' or 'readlink $(which sh)'.
For all other shell languages, "explicit-shell-file-name" gets set to the block
language name, literally, when "org-babel-shell-initialize" is called, such as
when ob-shell is first loaded. That word, such as "bash", will resolve
according to, I believe, "exec-path" (which is basically PATH).
Regarding org-babel-header-args, "org-babel-header-args:shell" is explicitly
set to '((async . ((yes no)))), it seems, to quiet the linter
(https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=40d1352b).
For other languages, such as "org-babel-header-args:bash", it's set to nil.
AFAICT, what you see are simply the default values.
I'm curious, what caused you to notice this inconsistency?
--
Matt Trzcinski
Emacs Org contributor (ob-shell)
Learn more about Org mode at https://orgmode.org
Support Org development at https://liberapay.com/org-mode