Changing shell used in %sh expansion?

Is it possible to change which shell is used when using %sh{…} expansions in function definitions?

You can only change the shell path with KAKOUNE_POSIX_SHELL environment variable.

Example – Using dash:

export KAKOUNE_POSIX_SHELL=/bin/dash

See #2547.

For a custom interpreter, you can do:

define-command my-command %{
  evaluate-commands %sh{
    cat <<'EOF' | crystal eval
      puts "echo 'Tchou'"
EOF
  }
}
1 Like

It’s important to note that majority of plugins expect the sh expansion to be POSIX shell compatible, so for example using shell like fish would break existing plugins.

Although, in case of plugin development, switching to shell such as dash, which more strictly follows POSIX shell conventions, helps keeping your code POSIX compliant, where as if you use the default bash shell, you need to use tools such as shellcheck more often.

2 Likes

Using fish will break lots of builtin scripts, not only external plugins.

Would be nice to be able to switch shell “locally” in some sense – per command or per buffer or something like that — sometimes it’s more pleasant to write a bunch of different one-off commands using fish or even perl