You can manually toggle which features Emacs will apply to your file via M-x sh-set-shell
: pick /bin/sh
to get the variant you prefer. You can set this automatically for a file by adding the following code at the end of the file:
# Local Variables:
# sh-shell: sh
# End:
To illustrate, with this file:
#!/bin/bash
alper=$(gdrive list --query "'$id' in parents" --no-header | grep "patch_")
# Local Variables:
# sh-shell: sh
# End:
I see this:

It doesn't change the #!
directive on the first line, and I get the syntax highlighting of the sh
style in a bash
script. This is with Emacs 28.0.50, started with emacs -Q
.
To enable this automatically for all bash scripts, you can use the following hook:
(defun my-set-shell ()
(sh-set-shell "sh"))
(add-hook 'sh-mode-hook 'my-set-shell)