I noticed this behaviour with kotlin
and kotlinc
tools.
Passing arguments starting with hyphens, like -b
, --blah
doesn’t work unless you provide and end of options terminator --
in the command line. AFAIK this is not documented anywhere.
kotlin
command line tool requires the following syntax:
kotlin hello.main.kts -- arg1 arg2 arg3 -b --blah
kotlinc
accepts the following syntax
kotlinc -script -- hello.main.kts arg1 arg2 arg3 -b --blah
IMO, kotlin
should accept the --
before the script path, so you can put it in the shebang line and the end user can ignore the above intricacies:
!#/usr/bin/env kotlin --
But this is currently not possible. However it can be worked around with kotlinc
as follows:
!#/usr/bin/env kotlinc -script --
Another questionable behaviour: your script can’t accept arguments -D
and -J
: these are processed by kotlin
/kotlinc
regardless of whether you provide the end of options terminator “--
”.