-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow executable scripts to not have any suffix (.sc or .scala) at all? #466
Comments
Adding it to the Scala CLI will not be that hard (we can detect if The only problem I see are support in Metals and Intellij since by default both tools looks at file extension. @tgodzik how hard would it be to add support for such scripts in Metals? |
I wouldn't mind if this wasn't available. But perhaps either or both environments have some way of looking at the contents of the first line? |
Support in Metals core wouldn't really be that much of an issue probably, but the tricky part would be everything around it. Depending on the client, the way Metals is triggered can be dependant on filetype, so it may be hard to actually edit this in isolation since Metals may not even be started when you open it in your editor. |
@tgodzik Can we also trigger metals based on the content of the file? e.g. existence of a shebang with scala-cli? |
This might be possible but it all depends on how VS Code will pick up the file and whether it will send it to Metals server. |
Just checked and some basic things work, but it might require a bunch of changes in Metals since we require |
I think this is the same issues that is triggered when trying to embed scala script in just. Since there's no filename to use anywhere and it's an embedded script it triggers an error on scala-cli:
Other language sripts (bash, python, perl, etc) all seem to work fine.
A sample project where I tried to use it - https://github.com/vascorsd/simple-scala . After installing just and trying to run |
After discussing it offline, there seems to be 2 potential solutions:
About variant 1
About variant 2
Seems like we should decide which is the lesser evil. |
Either way sounds fine to me. I really only care whether my single file scripts work and I can name them what I want to name them. |
I don’t think so, if |
Isn't it sufficient if the user manually selects the "language mode" for the file? |
It probably should, though not sure how well that will work. We assume in a lot of places that an extension is needed. |
I think we should go with Edit: We should not allow it to be run with run command. Can be done with |
👏 |
When 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 calledfoo
and not have to name itfoo.sc
orfoo.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 asfoo
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.)The text was updated successfully, but these errors were encountered: