Subject: Re: bug#17333: sh-mode: File local variables for setting shell variant

From: Ben Finney <[email-masked]>
Date: Wed, 30 Apr 2014 11:01:55 +1000

On 29-Apr-2014, Glenn Morris wrote:
> Ben Finney wrote:
> 
> > The 'sh-mode' appears to have no means for allowing a
> > non-executable file to declare, in its local variables, the shell
> > variant to use for syntax.
> 
> I'd also like a way to do this.
> In the past I've used
> 
> -*- mode: sh; eval: (sh-set-shell "tcsh" nil nil) -*-
> 
> but it is not great.

Partly because, AIUI, having ‘eval’ in the file's local variables is a
security hole, and is often disabled.

> Ideas that come to mind are a bunch of aliases (sh-bash-mode etc) that
> DTRT (yuck?); or sh-mode could add something to
> hack-local-variables-hook that respects a file-local `sh-buffer-shell'
> or somesuch.

I'd expect to be able to set the shell variant similar to the way that
I can set the SQL dialect::

    # Local variables:
    # coding: utf-8
    # mode: sql
    # sql-product: postgres
    # End:

So, for example::

    # Local variables:
    # coding: utf-8
    # mode: sh
    # shell-variant: bash
    # End:

would be a good interface for this feature, IMO.

-- 
 \     “I went to the cinema, it said ‘Adults: $5.00, Children $2.50’. |
  `\          So I said ‘Give me two boys and a girl.’” —Steven Wright |
_o__)                                                                  |
Ben Finney <[email-masked]>