I have some files that are not shell scripts per se, but designed to be sourced by shell scripts. Therefore, the file name don't match any pattern in auto-mode-alist
(nor am I interested in trying to update for each file).
When I edit one of my bash scripts (e.g., foo.bash), emacs properly deduces the shell and the mode line shows Shell-script[bash]
. Whether this is based on filename or shebang line is immaterial, I think. I'd like to force this behavior for my "non-script" script files.
What I came up with was this:
# -*- mode: Shell-script; eval (sh_set_shell "bash"); -*-
But that gives a warning about the eval
(rightly so). How else can I set the dialect for Shell-script mode?
CodePudding user response:
You can use a file local variables block and set sh-shell
in addition to the major mode:
# Local Variables:
# mode: shell-script
# sh-shell: bash
# End:
If you dislike this big (better readable :) ) block, a one liner will do niceley (per @jwm comment below):
# -*- mode: Shell-script; sh_shell: "bash"; -*-