question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow executable scripts to not have any suffix (.sc or .scala) at all?

See original GitHub issue

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 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:open
  • Created 2 years ago
  • Reactions:6
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
julienrfcommented, Nov 1, 2022
  • for example, when running scala-cli compile, should we run the ./compile file if it exists and contains the shebang line, or should we run the compile sub-command as normal?

I don’t think so, if ./compile is executable and has a shebang, then the intent is to run it with ./compile, not with scala-cli compile. The ability to also run it with an explicit scala-cli run compile or scala-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 invoking scala-cli rather than invoking the script itself.

1reaction
tgodzikcommented, Apr 21, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scala Scripting and the 15 Minute Blog Engine
Use the scala command to run script files: this works in theory, but in practice is unmaintained, and has enough rough edges (the...
Read more >
Using scala-cli to run Scala Scripts
To run Scala scripts very quickly without waiting the need for build tools, use scala-cli . Run​. For example, given this simple script:...
Read more >
Setting Up - Hands-on Scala
Scala Scripts are a lightweight way of running Scala code that is more convenient, though less configurable, than using a fully-featured build tool...
Read more >
Python nodes ending in .py · Issue #79 · ros/ros_tutorials
To keep the user API clean, executable script names generally do not include a .py suffix. However, the tutorials create nodes ending in...
Read more >
Scala CLI (Compiling and Running Code) | alvinalexander.com
sc extension. A main difference between the two is that a script doesn't have to have an @main method; it can just consist...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found