PSA: Julia 1.9 Change in argument processing --

@MilesCranmer discovered a bug in pyjulia that only manifested in Julia 1.9 due to a correction in argument processing.

Suppose we have a file printargs.jl with the following content.

println(ARGS)

If you placed a -- after the printargs.jl on the command line, you will get different results between Julia 1.8 and Julia 1.9:

$ julia-1.8.5/bin/julia --startup=no printargs.jl -- 1 2 3
["1", "2", "3"]

$ julia-1.9.0-beta4/bin/julia --startup=no printargs.jl -- 1 2 3
["--", "1", "2", "3"]

Julia 1.9 is processing the arguments correctly. Looking at the command line help, the -- is clearly suppose to come before the programfile. If it comes after, then it should be an argument.

$ julia-1.9.0-beta4/bin/julia --help                
    julia [switches] -- [programfile] [args...]
...

Putting the -- before the programfile results in consistent behavior between the versions.

$ julia-1.8.4/bin/julia --startup=no -- printargs.jl 1 2 3
["1", "2", "3"]

$ julia-1.9.0-beta2/bin/julia --startup=no -- printargs.jl 1 2 3
["1", "2", "3"]
4 Likes