scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

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

Open mpollmeier opened this issue 1 year ago • 0 comments

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 avatar Sep 14 '22 13:09 mpollmeier