fsi.CommandLineArgs is treating the -d, -r, and -I args differently to any other passed arg. When it has an arg ahead of it, the two args are joined together with a colon, rather than separated into two separate array items. This behaviour occurs even if these args follow -- (double dash).
An example of what happens:
[| "-d:5"; |] instead of [| "-d"; "5"; |]
This is not an underlying issue with System.Environment.GetCommandLineArgs(), as that method provides the expected results.
Repro steps
Create test.fsx with the following code:
printfn "%A" fsi.CommandLineArgs
Run with the following args to see the bare minimum needed for the bad cases:
dotnet fsi test.fsx -d 5 // [| "test.fsx"; "-d:5"; |]
dotnet fsi test.fsx -r 5 // [| "test.fsx"; "-r:5"; |]
dotnet fsi test.fsx -I 5 // [| "test.fsx"; "-I:5"; |]
Even running with -- doesn't change the result:
dotnet fsi test.fsx -- -d 5 // [| "test.fsx"; "--"; "-d:5"; |]
Run with the following args to see the expected behaviour:
dotnet fsi test.fsx -b 5 // [| "test.fsx"; "-b"; "5"; |]
dotnet fsi test.fsx -- -b 5 // [| "test.fsx"; "--"; "-b"; "5"; |]
5 can be anything.
Expected behavior
fsi.CommandLineArgs should be an array where the args separated by spaces are all individual strings.
If this is not the case, then -- should prevent the args from being mutated if the args follow it.
Actual behavior
Two args are combined into one and separated by a colon in a string. To the left of the colon is -d, -r, or -I. To the right is the item that follows.
Known workarounds
Use System.Environment.GetCommandLineArgs() if these specific args need to be used.
Related information
Windows 10
.NET 5.0
fsi.CommandLineArgsis treating the-d,-r, and-Iargs differently to any other passed arg. When it has an arg ahead of it, the two args are joined together with a colon, rather than separated into two separate array items. This behaviour occurs even if these args follow--(double dash).An example of what happens:
[| "-d:5"; |]instead of[| "-d"; "5"; |]This is not an underlying issue with
System.Environment.GetCommandLineArgs(), as that method provides the expected results.Repro steps
Create
test.fsxwith the following code:printfn "%A" fsi.CommandLineArgsRun with the following args to see the bare minimum needed for the bad cases:
dotnet fsi test.fsx -d 5//[| "test.fsx"; "-d:5"; |]dotnet fsi test.fsx -r 5//[| "test.fsx"; "-r:5"; |]dotnet fsi test.fsx -I 5//[| "test.fsx"; "-I:5"; |]Even running with
--doesn't change the result:dotnet fsi test.fsx -- -d 5//[| "test.fsx"; "--"; "-d:5"; |]Run with the following args to see the expected behaviour:
dotnet fsi test.fsx -b 5//[| "test.fsx"; "-b"; "5"; |]dotnet fsi test.fsx -- -b 5//[| "test.fsx"; "--"; "-b"; "5"; |]5can be anything.Expected behavior
fsi.CommandLineArgsshould be an array where the args separated by spaces are all individual strings.If this is not the case, then
--should prevent the args from being mutated if the args follow it.Actual behavior
Two args are combined into one and separated by a colon in a string. To the left of the colon is
-d,-r, or-I. To the right is the item that follows.Known workarounds
Use System.Environment.GetCommandLineArgs() if these specific args need to be used.
Related information
Windows 10
.NET 5.0