Skip to content

scala script exit code should be non-0 for missing parameters #16040

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

Open
mpollmeier opened this issue Sep 14, 2022 · 1 comment
Open

scala script exit code should be non-0 for missing parameters #16040

mpollmeier opened this issue Sep 14, 2022 · 1 comment

Comments

@mpollmeier
Copy link
Contributor

Compiler version

3.2.0

Minimized code

fun.sc:

@main def fun(i: Int): Unit = {
  println("foo")
}
scala fun.sc
echo $?

Output

Illegal command line: more arguments expected
0

Expectation

The exit code of the process should not be 0, so that the usage side can infer that an error happened. For reference, if the main method contains code that throws an exception, the exit code is 1.

Initial Analysis

CommandLineParser throws a ParserError, which is caught by the handler that MainProxies generates here, as documented here.

@mpollmeier mpollmeier added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 14, 2022
@KacperFKorban KacperFKorban added area:scripting and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 14, 2022
@gaeljw
Copy link

gaeljw commented Jan 31, 2025

Still facing this issue with Scala 3.6.3. This makes any serious usage of @main impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants