emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: ("bash" . sh) in default value of org-src-lang-modes
@ 2021-03-27 15:04 Sebastian Miele
  0 siblings, 0 replies; only message in thread
From: Sebastian Miele @ 2021-03-27 15:04 UTC (permalink / raw)
  To: emacs-orgmode

Hello!

The default value of org-src-lang-modes contains ("bash" . sh), meaning
that for bash src blocks sh-mode gets used.

sh-mode supports many different languages (bash, zsh, dash, ...).
Often, when opening a file for which sh-mode gets activated, there is
enough information for sh-mode to determine the language that actually
is used in the file, e.g., by a shebang, or by the suffix of the
filename.

However, that usually does not work with Org src blocks.  When sh-mode
has no clues, it in effect always uses the language determined by the
SHELL environment variable (at least on POSIX-conformant systems).  If
that is not something like /bin/bash then sh-mode is not a bash mode.
E.g., with SHELL=/bin/zsh opening an edit buffer for

#+BEGIN_SRC bash
#+END_SRC

yields a buffer with the buffer-local variable sh-shell set to zsh
instead of bash, i.e., sh-shell is a zsh mode.

This can be fixed by defining something like

(defun org-babel-bash-mode ()
  (sh-mode)
  (sh-set-shell "bash"))

and having ("bash" . org-babel-bash) in the default value of
org-src-lang-mode.

Best wishes
Sebastian


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-27 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-27 15:04 Bug: ("bash" . sh) in default value of org-src-lang-modes Sebastian Miele

Code repositories for project(s) associated with this 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).