GeezerVison is showing github.com — Fix global tool issues around exit code, command line parameters and … · PowerShell/PowerShell@42b599d
File tree
Expand file treeCollapse file tree
Open diff view settings
src/Microsoft.PowerShell.GlobalTool.Shim
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs +7-4Lines changed: 7 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,8 +21,9 @@ public class EntryPoint |
21 | 21 | /// <summary> |
22 | 22 | /// Entry point for the global tool. |
23 | 23 | /// </summary> |
24 | | - /// <param name="args">Arguments passed to the global tool.</param> |
25 | | - public static void Main(string[] args) |
| 24 | + /// <param name="args">Arguments passed to the global tool.</param>' |
| 25 | + /// <returns>Exit code returned by pwsh.</returns> |
| 26 | + public static int Main(string[] args) |
26 | 27 | { |
27 | 28 | var currentPath = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).Directory.FullName; |
28 | 29 | var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); |
@@ -31,11 +32,13 @@ public static void Main(string[] args) |
31 | 32 |
|
32 | 33 | string argsString = args.Length > 0 ? string.Join(" ", args) : null; |
33 | 34 | var pwshPath = Path.Combine(currentPath, platformFolder, PwshDllName); |
34 | | - string processArgs = string.IsNullOrEmpty(argsString) ? $"{pwshPath}" : $"{pwshPath} -c {argsString}"; |
| 35 | + string processArgs = string.IsNullOrEmpty(argsString) ? $"\"{pwshPath}\"" : $"\"{pwshPath}\" {argsString}"; |
35 | 36 |
|
36 | 37 | if (File.Exists(pwshPath)) |
37 | 38 | { |
38 | | - System.Diagnostics.Process.Start("dotnet", processArgs).WaitForExit(); |
| 39 | + var process = System.Diagnostics.Process.Start("dotnet", processArgs); |
| 40 | + process.WaitForExit(); |
| 41 | + return process.ExitCode; |
39 | 42 | } |
40 | 43 | else |
41 | 44 | { |
|