*nix: dotnet subcommands incorrectly splitting quoted args containing spaces
See original GitHub issueSteps 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:
- Created 7 years ago
- Comments:16 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 settingDOTNET_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:
/opt/dotnet/dotnet
to invoke (e.g./opt/dotnet/dotnet run foo "bar baz"
)./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.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.