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

不问归期 提交于 2019-11-30 21:15:20
Keith Pinson

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

As I can test, just

#!/usr/bin/env scala
!#

println("Args: " + args.toList)

works fine:

➜ ./test.scala 1 hi
Args: List(1, hi)

Or you may write it without /usr/bin/env, for fixed scala path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!