Skip to content

fsi.CommandLineArgs different behavior on -d/-r/-I args, ignores --. #10819

Description

@JamesMarionTech

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FSIBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No fields configured for Bug.

    Projects

    Status
    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions