diff options
author | Daniel C. Sobral <dcsobral@gmail.com> | 2011-09-14 18:45:48 -0300 |
---|---|---|
committer | Daniel C. Sobral <dcsobral@gmail.com> | 2011-12-01 17:40:45 -0200 |
commit | 8b8ed9980b9f35a16cd55744937e67cff02ea6f1 (patch) | |
tree | b2c4bbdad800eeb17674bda719b1fff64a2a6521 /src/compiler | |
parent | fab4292f0424a7a49c3027e58d88e7d157e2e515 (diff) | |
download | scala-8b8ed9980b9f35a16cd55744937e67cff02ea6f1.tar.gz scala-8b8ed9980b9f35a16cd55744937e67cff02ea6f1.tar.bz2 scala-8b8ed9980b9f35a16cd55744937e67cff02ea6f1.zip |
Makes it possible to use env(1) to run scala scripts, by dropping
the requirement of a !# line when using it. This is how some other
languages, such as ruby, are run.
Typical usage:
#!/usr/bin/env scala
println("Hello, "+args(0)+"!")
Contributed by: Daniel C. Sobral
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/util/SourceFile.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala index 22820806be..4405b3457b 100644 --- a/src/compiler/scala/tools/nsc/util/SourceFile.scala +++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala @@ -72,7 +72,7 @@ object ScriptSourceFile { * with "!#" or "::!#". */ def headerLength(cs: Array[Char]): Int = { - val headerPattern = Pattern.compile("""^(::)?!#.*(\r|\n|\r\n)""", Pattern.MULTILINE) + val headerPattern = Pattern.compile("""((?m)^(::)?!#.*|^.*/env .*)(\r|\n|\r\n)""") val headerStarts = List("#!", "::#!") if (headerStarts exists (cs startsWith _)) { |