sdk: *nix: dotnet subcommands incorrectly splitting quoted args containing spaces
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
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- Merge pull request #8753 from natemcmaster/master Fix #4139 - escape quoted strings for process start — committed to dotnet/cli by peterhuene 6 years ago
- Merge remote-tracking branch 'upstream/release/2.1.3xx' into merges/release/2.1.3xx-to-master * upstream/release/2.1.3xx: Try shorter test names Fix project type GUIDs when adding projects to sol... — committed to dotnet/cli by deleted user 6 years ago
- Merge branch 'release/2.1.3xx' into master * upstream/release/2.1.3xx: Try shorter test names Fix project type GUIDs when adding projects to solution files. Updating the runtime to 2.1.0-previe... — committed to dotnet/cli by deleted user 6 years ago
- Merge branch 'release/2.1.3xx' into master * upstream/release/2.1.3xx: Try shorter test names Fix project type GUIDs when adding projects to solution files. Updating the runtime to 2.1.0-previe... — committed to dotnet/cli by deleted user 6 years ago
The issue on Arch Linux is how
dotnetis being packaged.It’s installing .NET Core into a non-standard location of
/opt/dotnet/dotnetand then using a shell script at/usr/bin/dotnetto invoke/opt/dotnet/dotnetafter settingDOTNET_ROOTto 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/dotnetto invoke (e.g./opt/dotnet/dotnet run foo "bar baz")./usr/bin/dotnetand change$@to"$@"to preserve the quotes.An issue should be filed with the Arch Linux bug tracker for the
community/dotnet-hostpackage regarding fixing the/usr/bin/dotnetwrapper 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.
reported against the arch bugtracker as https://bugs.archlinux.org/task/61427
I’m currently encountering this issue on ArchLinux using zsh, bash and sh. dotnet --info puts me at version 2.2.100 for the sdk and 2.2.0 for the host version.
Using the 3.0.100-preview-009752 fixes the issue.