emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ob-shell: async support in "shell" vs "bash"
@ 2024-06-10  2:33 Suhail Singh
  2024-06-16 18:32 ` Matt
  0 siblings, 1 reply; 4+ messages in thread
From: Suhail Singh @ 2024-06-10  2:33 UTC (permalink / raw)
  To: Org mailing list

On my system both "shell" and "bash" language blocks use "bash" as
checked by:

    #+begin_src shell :results replace
      cat /proc/$$/comm
    #+end_src

    #+RESULTS:
    : bash

    #+begin_src bash :results replace
      cat /proc/$$/comm
    #+end_src

    #+RESULTS:
    : 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?

-- 
Suhail


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

* Re: ob-shell: async support in "shell" vs "bash"
  2024-06-10  2:33 ob-shell: async support in "shell" vs "bash" Suhail Singh
@ 2024-06-16 18:32 ` Matt
  2024-06-16 22:02   ` Suhail Singh
  0 siblings, 1 reply; 4+ messages in thread
From: Matt @ 2024-06-16 18:32 UTC (permalink / raw)
  To: Suhail Singh; +Cc: Org mailing list

 ---- 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




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

* Re: ob-shell: async support in "shell" vs "bash"
  2024-06-16 18:32 ` Matt
@ 2024-06-16 22:02   ` Suhail Singh
  2024-06-17 15:36     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Suhail Singh @ 2024-06-16 22:02 UTC (permalink / raw)
  To: Matt; +Cc: Suhail Singh, Org mailing list

Matt <matt@excalamus.com> writes:

> :async should work for all shell types.

Thank you for confirming the expected behaviour.

> Are you finding that it's not?

No.  However, on language-specific shell code blocks (e.g. "bash")
org-lint reports warnings.

> Regarding org-babel-header-args, "org-babel-header-args:shell" is
> explicitly set to '((async . ((yes no)))), it seems, to quiet the
> linter

Indeed, it does.  For "shell" source blocks, but not for specific
language blocks such as "bash".

> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=40d1352b

I believe there's a bug in that commit.  Specifically, the commit
message states:

#+begin_quote
  Propagate base `org-babel-header-args:shell'
  to`org-babel-header-args:<shell-name>'.
#+end_quote

However, the code initializes org-babel-header-args:<shell-name> to nil,
instead.

> For other languages, such as "org-babel-header-args:bash", it's set to
> nil.  AFAICT, what you see are simply the default values.

Indeed.  It seems to me that the appropriate default for
org-babel-header-args:<shell-name> should be the same as that for
org-babel-header-args:shell , yet it's not.

> I'm curious, what caused you to notice this inconsistency?

Org-lint (in my specific case, I have it configured to run on save via
flycheck).

-- 
Suhail


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

* Re: ob-shell: async support in "shell" vs "bash"
  2024-06-16 22:02   ` Suhail Singh
@ 2024-06-17 15:36     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-06-17 15:36 UTC (permalink / raw)
  To: Suhail Singh; +Cc: Matt, Org mailing list

Suhail Singh <suhailsingh247@gmail.com> writes:

>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=40d1352b
>
> I believe there's a bug in that commit.  Specifically, the commit
> message states:
>
> #+begin_quote
>   Propagate base `org-babel-header-args:shell'
>   to`org-babel-header-args:<shell-name>'.
> #+end_quote
>
> However, the code initializes org-babel-header-args:<shell-name> to nil,
> instead.

Thanks for the analysis!
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e666660c7

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2024-06-17 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-10  2:33 ob-shell: async support in "shell" vs "bash" Suhail Singh
2024-06-16 18:32 ` Matt
2024-06-16 22:02   ` Suhail Singh
2024-06-17 15:36     ` Ihor Radchenko

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).