From eec3b334cc5e1cfd69fff291bac2b6984577f184 Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Tue, 21 Jun 2016 12:52:40 -0700 Subject: [PATCH] Adding logic for invoke-item for non-Windows OSes --- .../namespaces/FileSystemProvider.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 8f691de069..e10a175945 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -1331,7 +1331,22 @@ namespace Microsoft.PowerShell.Commands if (ShouldProcess(resource, action)) { - System.Diagnostics.Process.Start(path); + System.Diagnostics.Process invokeProcess = new System.Diagnostics.Process(); + invokeProcess.StartInfo.UseShellExecute = true; + + if (Platform.IsWindows) + { + System.Diagnostics.Process.Start(path); + } else if (Platform.IsOSX) { + invokeProcess.StartInfo.FileName = "open"; + invokeProcess.StartInfo.Arguments = path; + } else if (Platform.IsLinux) { + invokeProcess.StartInfo.FileName = "xdg-open"; + invokeProcess.StartInfo.Arguments = path; + } + invokeProcess.Start(); + + //System.Diagnostics.Process.Start(path); } } // InvokeDefaultAction @@ -7784,7 +7799,7 @@ namespace Microsoft.PowerShell.Commands private bool wait; /// - /// When the –Raw switch is present, we don’t do any breaks on newlines, + /// When the �Raw switch is present, we don�t do any breaks on newlines, /// and only emit one object to the pipeline: all of the content. /// [Parameter]