Skip to content

*nix: dotnet subcommands incorrectly splitting quoted args containing spaces #6807

@natemcmaster

Description

@natemcmaster

Steps to reproduce

To see problem, use this:

using System;

class Program
{
    static void Main(string[] args)
    {
        for(var i = 0; i < args.Length; i++)
        {
            Console.WriteLine($"{i} = {args[i]}");
        }
    }
}

Execute dotnet run a b '" c "' d

Expected behavior

Output should be:

0 = a
1 = b
2 = " c "
3 = d

Actual behavior

0 = a
1 = b
2 = "
3 = c
4 = "
5 = d

Environment data

Repros in preview2 and preview3 nightlies, bash on Linux and OSX

dotnet --info output:

.NET Command Line Tools (1.0.0-preview3-003546)

Product Information:
 Version:            1.0.0-preview3-003546
 Commit SHA-1 hash:  c0c07ed959

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  14.04
 OS Platform: Linux
 RID:         ubuntu.14.04-x64

More info

The problem appears to be somewhere in CLI. Using dotnet exec does not have this problem.

namc@ubuntu:/tmp/quoted$ dotnet exec --depsfile bin/Debug/netcoreapp1.0/quoted.deps.json --runtimeconfig bin/Debug/netcoreapp1.0/quoted.runtimeconfig.json bin/Debug/netcoreapp1.0/quoted.dll a b '" c "' d
0 = a
1 = b
2 = " c "
3 = d

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions