scala3
scala3 copied to clipboard
scala script exit code should be non-0 for missing parameters
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.