From 9b894b3b92001f48bde1e3b53fadf2e295bcdfbd Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 22 Jun 2022 07:55:47 +1000 Subject: [PATCH] update comment regarding usage of Argument vs ArgumentList --- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index 6797a0f67..ae74aa804 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -194,7 +194,8 @@ namespace Flow.Launcher.Plugin.Shell ProcessStartInfo info = new() { - Verb = runAsAdministratorArg, WorkingDirectory = workingDirectory, + Verb = runAsAdministratorArg, + WorkingDirectory = workingDirectory, }; switch (_settings.Shell) { @@ -202,10 +203,20 @@ namespace Flow.Launcher.Plugin.Shell { info.FileName = "cmd.exe"; info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command}"; - - // ArgumentList may break original shell command separation with quote. + + //// Use info.Arguments instead of info.ArgumentList to enable user better control over the argument they are writing. + //// Previous code using ArgumentList, commands needed to be seperated correctly: + //// Incorrect: // info.ArgumentList.Add(_settings.LeaveShellOpen ? "/k" : "/c"); - // info.ArgumentList.Add(command); + // info.ArgumentList.Add(command); //<== info.ArgumentList.Add("mkdir \"c:\\test new\""); + + //// Correct version should be: + //info.ArgumentList.Add(_settings.LeaveShellOpen ? "/k" : "/c"); + //info.ArgumentList.Add("mkdir"); + //info.ArgumentList.Add(@"c:\test new"); + + //https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.argumentlist?view=net-6.0#remarks + break; }