question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

*nix: dotnet subcommands incorrectly splitting quoted args containing spaces

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
peterhuenecommented, Jan 16, 2019

The issue on Arch Linux is how dotnet is being packaged.

It’s installing .NET Core into a non-standard location of /opt/dotnet/dotnet and then using a shell script at /usr/bin/dotnet to invoke /opt/dotnet/dotnet after setting DOTNET_ROOT to point at /opt/dotnet/dotnet. This shell script does not preserve the quotes when forwarding the arguments to /opt/dotnet/dotnet.

Possible workarounds:

  • Use /opt/dotnet/dotnet to invoke (e.g. /opt/dotnet/dotnet run foo "bar baz").
  • Edit /usr/bin/dotnet and change $@ to "$@" to preserve the quotes.

An issue should be filed with the Arch Linux bug tracker for the community/dotnet-host package regarding fixing the /usr/bin/dotnet wrapper script.

2reactions
peterhuenecommented, Dec 26, 2018

Hi @Vogel612,

I’m unable to reproduce this issue with either 2.2.100 or 2.2.101 (the most recent SDK version), at least on macOS. Unfortunately I’m far away from my Arch system (which is powered down), but I can try to reproduce it in a VM if you like.

The fix should have made it into 2.1.300 and I see it tagged all the way through to the current release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

*nix: dotnet subcommands incorrectly splitting quoted args ...
Steps to reproduce To see problem, use this: using System; class Program { static void Main(string[] args) { for(var i = 0; i...
Read more >
How to avoid that a string splits on every whitespace in ...
1 Answer 1 ... MSDN: Command line arguments are delimited by spaces. You can use double quotation marks (") to include spaces within...
Read more >
picocli - a mighty tiny command line interface
Arguments containing whitespace do not need to be quoted, but it is not possible to have arguments with embedded newlines or to have...
Read more >
Nixpkgs 23.05 manual
Nix is a tool that takes a unique approach to package management and system configuration. Learn how to make reproducible, declarative and reliable...
Read more >
Untitled
Rot gelb blau sind, A christmas story quotes furnace, Jeep sunroof class action? ... C# backgroundworker isbusy problem, Mehelle 3 tek parca, Jochen...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found