Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProcessStartInfo.Arguments follows Windows conventions on all platforms #29857

Closed
CoffeeFlux opened this issue Jun 12, 2019 · 7 comments
Closed

Comments

@CoffeeFlux
Copy link
Contributor

Related issue in Mono: mono/mono#14724

It seems that currently in .NET Core, ProcessStartInfo.Arguments follows Windows argument conventions on all platforms. As shown in the linked issue, this leads to significant differences in common scenarios, single quotes being an easy example.

I wanted to open this issue to clarify whether that is intended, or if there's any chance of Core using POSIX shell conventions on platforms when appropriate. I'm somewhat concerned that Mono customers depend on the current behavior, which is what I would personally expect to see on non-Windows platforms, but I don't know how similar platform differences are typically handled in Core. If following Windows conventions on all platforms is intentional, we'll figure out how to deal with that along with existing applications, but I wanted to clarify/see if there's any chance for a change here.

@krwq
Copy link
Member

krwq commented Jun 17, 2019

@CoffeeFlux for 3.0 this is by design and we do not intend to change this behavior at this point (too close to ship date).

For Future we can start a conversation on how to make both Windows and Linux users happy (will have to add new APIs if needed).

I'd recommend to list what behaviors do you think should be changed (in a table) and what would be implications of that for Windows and Linux users and based on that we can decide what to do going forward.

@EgorBo
Copy link
Member

EgorBo commented Jun 17, 2019

@CoffeeFlux
Copy link
Contributor Author

Speaking personally, I think the managed API here is too Windows-centric, and as part of .NET 5 we should be looking to accomplish two main things:

  1. Extend the API to allow for passing in an array of strings instead of the single flat string taken by ProcessStartInfo.Arguments – something like ProcessStartInfo.ArgumentArray. This could be passed directly to exec on POSIX, and will save non-Windows users the trouble of messing with quotes in an effort to get the behavior they want. Sadly, no such option exists on Windows, and so we would have to do quoting/escaping on the elements before calling CreateProcess on Windows, which gets messy.
  2. Look at existing customer usage of ProcessStartInfo.Arguments for both .NET Core and Mono, and then decide how to best standardize the behavior between the runtimes. I could see a reasonable argument for requiring Windows conventions on all platforms for uniformity or for following POSIX conventions as appropriate to produce intuitive behavior, and so I think community input is a good first step towards deciding how to unify the behavior while causing as little friction as possible for customers.

In general, it would be nice to have fundamental questions like this tracked somewhere, but that's well outside my domain. I've pinged the Mono BCL team about this issue and hopefully one of them can take a look and share their thoughts/come up with a more formal proposal.

@stephentoub
Copy link
Member

Extend the API to allow for passing in an array of strings instead of the single flat string taken by ProcessStartInfo.Arguments – something like ProcessStartInfo.ArgumentArray.

That already exists.
https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.argumentlist?view=netcore-3.0#System_Diagnostics_ProcessStartInfo_ArgumentList

@CoffeeFlux
Copy link
Contributor Author

CoffeeFlux commented Jun 20, 2019

Ah okay, I guess I was looking at Framework documentation by accident, my bad. That should work well for Unix users, though it seems inconsistent on whether Arguments or ArgumentList takes priority depending on platform with the reverse of what I'd actually expect; Windows seems to prefer ArgumentList while Unix prefers Arguments. https://github.com/dotnet/corefx/blob/41f0787f93d6c51baf3cd90b39b6e572ce5c6582/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Win32.cs#L52-L61 https://github.com/dotnet/corefx/blob/007571b90c3cc555cd30f3b467b87c22f9f665e0/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs#L596-L603

I think my second point still more or less stands.

@TSlivede
Copy link

TSlivede commented Jul 23, 2019

  1. [...] and then decide how to best standardize the behavior between the runtimes. I could see a reasonable argument for requiring Windows conventions on all platforms for uniformity

My thoughts (as you requested community input 😃 ):

IMHO, I think it must always be the Windows behavior for ProcessStartInfo.Arguments, because yes, sure, intuitiveness would be nice - but if it isn't consistent one cannot write platform independent apps, and that would defeat the purpose of having a framework for multiple platforms.

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the Future milestone Feb 1, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 23, 2020
@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Jul 6, 2020
@tmds
Copy link
Member

tmds commented Sep 15, 2021

This issue can be closed. As explained above, this behavior is intentional.

@krwq krwq closed this as completed Sep 15, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants