0

Emacs is treating my Scala code as shell scripts due to an incorrect mimetype being set:

file -I Hello.scala
Hello.scala: text/x-shellscript; charset=us-ascii

I tried changing the Open with... information for the file, but Mac still uses the wrong mimetype. How can I fix the mimetype, preferably with a Terminal.app command?

2
  • cp and cat both copy over the source mimetype, so it's not easy to get around this issue by making a new file and copying the source into it.
    – mcandre
    Feb 25, 2013 at 20:49
  • Is the problem that you want Emacs to know what type it is (in which case you want auto-mode-alist), that you want the Mac's "open with..." to know what the file type is (in which case you might want Universal Type Identifiers), or that you want the file command to know what type the file is (which uses files in the /usr/share/file/magic directory)? Since each uses a different method, the route to fixing it will depend on what you're trying to do. Let us know and I think I can tell you how to fix it. Feb 25, 2013 at 22:44

1 Answer 1

0

Turns out shebang lines are to blame.

#!/bin/sh
exec scala "$0" "$@"
!#

These are necessary in order to dot-slash Scala programs, but they are also used to determine a file's mimetype, albeit incorrectly so.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .