From 8b8ed9980b9f35a16cd55744937e67cff02ea6f1 Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Wed, 14 Sep 2011 18:45:48 -0300 Subject: 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 --- src/compiler/scala/tools/nsc/util/SourceFile.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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 _)) { -- cgit v1.2.3