The scala interpreter allows shebangs, but strangely, scalac borks on them. Are there any tricks like these to get around this flaw?
Asked
Active
Viewed 380 times
3 Answers
2
#! in scala must be closed with !#. For example:
#!/bin/bash
script_dir=$(cd $(dirname "$0") >/dev/null; pwd -P)
classes_dir=${script_dir}/build/classes
src_dir=${script_dir}/src
mkdir -p ${classes_dir}
scalac -d ${classes_dir} $(find ${src_dir} -name '*.scala')
exec /usr/bin/scala -classpath ${classes_dir} "$0" "$@"
!#

Noel Yap
- 18,822
- 21
- 92
- 144
0
Why not strip them transparently before invoking scalac
in your build script?

user268396
- 11,576
- 2
- 31
- 26
-
I'd like to not have to strip any code. I'm willing to use obscure shebang syntax if necessary to achieve this. – mcandre Nov 11 '11 at 01:15
0
I don't think this is a question of "obscure shebang syntax", but rather a "language specification" issue.
The Wikipedia article on Shebang does mention:
The contents of the shebang line will be automatically ignored by the interpreter, because the
#
character is a comment marker in many scripting languages.
Some language interpreters that do not use the hash mark to begin comments, such as Scheme, still may ignore the shebang line.
So if scalac hasn't in its specification the directives to ignore the first lines as "script header" like Scheme, we need to wait on your Jira case 5179.

VonC
- 1,262,500
- 529
- 4,410
- 5,250