Save raw command instead of resolved command in shell history (#10000)

This commit is contained in:
Sean Lin
2021-03-04 09:04:31 -08:00
committed by GitHub
parent 8f3e0517ca
commit f648ac44b2

View File

@@ -156,8 +156,8 @@ namespace Microsoft.Plugin.Shell
private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdministrator = false) private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdministrator = false)
{ {
command = command.Trim(); string trimmedCommand = command.Trim();
command = Environment.ExpandEnvironmentVariables(command); command = Environment.ExpandEnvironmentVariables(trimmedCommand);
var workingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var workingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var runAsAdministratorArg = !runAsAdministrator && !_settings.RunAsAdministrator ? string.Empty : "runas"; var runAsAdministratorArg = !runAsAdministrator && !_settings.RunAsAdministrator ? string.Empty : "runas";
@@ -218,7 +218,7 @@ namespace Microsoft.Plugin.Shell
info.UseShellExecute = true; info.UseShellExecute = true;
_settings.AddCmdHistory(command); _settings.AddCmdHistory(trimmedCommand);
return info; return info;
} }