문제

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.

#!/bin/sh
exec scala "$0" "$@"
!#
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top