diff --git a/modules/cli/src/main/scala/scala/cli/ScalaCli.scala b/modules/cli/src/main/scala/scala/cli/ScalaCli.scala index 2f3f3d1085..7115fc19f8 100644 --- a/modules/cli/src/main/scala/scala/cli/ScalaCli.scala +++ b/modules/cli/src/main/scala/scala/cli/ScalaCli.scala @@ -234,12 +234,15 @@ object ScalaCli { isSipScala = false args0.toArray else + // .ignoreUnrecognized drops '--' + val programArgs = args0.dropWhile(_ != "--") + val optionArgs = args0.takeWhile(_ != "--") // Parse again to consume --power at any position - PowerOptions.parser.ignoreUnrecognized.parse(args0) match { + PowerOptions.parser.ignoreUnrecognized.parse(optionArgs) match { case Right((powerOptions, unrecognizedArgs)) => if powerOptions.power then isSipScala = false - unrecognizedArgs.toArray + (unrecognizedArgs ++ programArgs).toArray case Left(e) => System.err.println(e.message) sys.exit(1)