Subject: Re: bug#13815: Wrong mode for files with awkward shebang lines

From: Glenn Morris <[email-masked]>
Date: Mon, 25 Feb 2013 22:02:22 -0500

Andrew Pennebaker wrote:

> #!/bin/sh
> exec scala "$0" "$@"
[...]
> This creates problems for Emacs, as Emacs uses `file` to detect which major
> mode should be used,

Emacs does not use `file', it uses interpreter-mode-alist (amongst other
things).

> This could be solved a variety of ways, but I think the simplest is to
> prioritize file extension over mimetype when a file extension is available.

It used to work that way prior to Emacs 22.1. Then it was changed for
reasons that were never properly explained IMO.

http://debbugs.gnu.org/3354

All you can do is add a mode: cookie.

Or use /usr/bin/env, IIUC
https://github.com/scala/scala/pull/9