Allow executable scripts to not have any suffix (.sc or .scala) at all?
See original GitHub issueWhen you’re using Scala as a scripting language, with #!/usr/bin/env scala-cli shebang
, it would be nice if I could just have an executable script called foo
and not have to name it foo.sc
or foo.scala
.
For me as the author of the script having the suffix is not so bad, but for those who are using my script, it might be weird and annoying to have to say foo.sc
; they would prefer to just run the script as foo
and not even care whether it’s written in C or Shell or Scala or what have you. To the user it’s just some executable thing. Perhaps it’s even on their $PATH
.
I’ve been writing scripts for decades now in Perl, Bash, Scala, and assorted other languages and none of those languages have disallowed me from using a bare filename. (I have Scala on that list because until recently I was using sbt’s ScriptMain
support, which allowed this.)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:12 (9 by maintainers)
Top GitHub Comments
I don’t think so, if
./compile
is executable and has a shebang, then the intent is to run it with./compile
, not withscala-cli compile
. The ability to also run it with an explicitscala-cli run compile
orscala-cli --run-script compile
sounds fine to me, but I really don’t think we need to provide a way to run that script by invokingscala-cli
rather than invoking the script itself.Just checked and some basic things work, but it might require a bunch of changes in Metals since we require
.scala
in the path and now we would need to actually read the file. So an effective way to do that would probably be needed.