What's a shebang line for Scala that doesn't corrupt mimetype?

前端 未结 2 956
走了就别回头了
走了就别回头了 2021-01-05 16:24

I\'ve been using this, but it changes the mimetype to text/x-shellscript, which makes editors like Emacs treat my code like Shell scripts.

#!/bi         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-05 17:12

    The bangshe (!#) might be the problem

    I commented out the !# and the following works in my environment:

    File: hello.sh

    #!/usr/bin/env scala
    
    val name = readLine("What is your name? ")
    println("Hello " + name + "!")
    

    Changed to executable permissions and then ran:

    chmod a+x hello.scala
    ./hello.scala
    

提交回复
热议问题