-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
UseShellExecute on macOS passes Arguments to open
instead of specified filename
#26640
Comments
@SteveL-MSFT how does 'open' get into play here? Is that something .NET Core invokes when UseShellExecute=true? |
@karelz Yes, .NET Core invokes
Probably something similar for the Linux code path, but I only tested this on macOS. |
That sounds fairly straightforward. @wtgodbe what do you think? |
Seems reasonable. Looking into code paths now. To start with, looks like this is the start of the bad path: |
Looks like we just need to modify https://github.com/dotnet/corefx/blob/4e27e0ad415dda38c2c2add84f0315a6f56406b3/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs#L398-L426 to append |
@karelz this is not blocking PowerShell Core. Since enabling UseShellExecute on non-Windows is new capability, to workaround this, if the user passed Arguments, we simply set UseShellExecute to false. not ideal, but sufficient for now. The main scenario we wanted to enable is supporting |
@karelz @SteveL-MSFT do either of you guys know how to best test a fix with powershell? I have a fix prepared, but I don't know how to get powershell to target my local build of CoreFx. |
@wtgodbe I believe you can just overwrite the corefx assembly in $PSHOME |
Actually in testing without my change, I get a different result than you did. My output is:
However, running |
I'm also having trouble testing with a local version of CoreFx - after copying in CoreFx libraries, I'm getting errors like:
|
@wtgodbe that exception is complaining it can't find SMA.dll at that location. Did you only overwrite the single assembly? |
I did, in that case I get:
If I follow the chain & copy over the other dependencies (
|
@wtgodbe looking at your ShellExecute branch, it appears you branched off master which is way ahead of 2.1.x release branch which is what PSCore6.1 is currently built against. I think to test your fix against PSCore6.1, you should apply your change to the 2.1.x release branch and build off that. I built a private off your fork using However, it appears that
I expected a new instance of PSCore6.1 to start and run |
The alternative is to allow passing args, but document that on non-Windows (not a fan of this inconsistency), the args get passed the default app (on Windows, it does get passed to the executable at least in the |
The original issue reported here should be fixed by dotnet/corefx#33052. |
@tmds @SteveL-MSFT can we close this then? If there is more to do then another issue might be clearest |
If this is fixed in 3.0, we can close this. Not sure when we can move PowerShell Core 6 to 3.0. |
fixed then. |
Using PSCore6:
Expected:
Start new instance of PowerShell outputting answer of
2
and waiting forEnter
, then exit.Actual:
Help for
open
command is displayed since-c
is not valid.When using
open
, arguments to the executable are passed as--args <arguments>
The above script works as expected on Windows.
The text was updated successfully, but these errors were encountered: