Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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 '13 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. –  Alan Shutko Feb 25 '13 at 22:44

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.