Skip to content

Commit

Permalink
[EnvVar]Do not expand variables when looking for backup variables (#2…
Browse files Browse the repository at this point in the history
…9431)

* [EnvVar] Do not expand when looking for backup variable

* Revert unneeded change
  • Loading branch information
stefansjfw authored Oct 26, 2023
1 parent 04a7adf commit 1dde699
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ internal static string GetBackupVariableName(Variable variable, string profileNa

internal static Variable GetExisting(string variableName)
{
var userVariables = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User);
DefaultVariablesSet userSet = new DefaultVariablesSet(Guid.NewGuid(), "tmpUser", VariablesSetType.User);
GetVariables(EnvironmentVariableTarget.User, userSet);

foreach (DictionaryEntry variable in userVariables)
foreach (var variable in userSet.Variables)
{
var key = variable.Key as string;
if (key.Equals(variableName, StringComparison.OrdinalIgnoreCase))
if (variable.Name.Equals(variableName, StringComparison.OrdinalIgnoreCase))
{
return new Variable(key, userVariables[key] as string, VariablesSetType.User);
return new Variable(variable.Name, variable.Values, VariablesSetType.User);
}
}

var systemVariables = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine);
DefaultVariablesSet systemSet = new DefaultVariablesSet(Guid.NewGuid(), "tmpSystem", VariablesSetType.System);
GetVariables(EnvironmentVariableTarget.Machine, systemSet);

foreach (DictionaryEntry variable in systemVariables)
foreach (var variable in systemSet.Variables)
{
var key = variable.Key as string;
if (key.Equals(variableName, StringComparison.OrdinalIgnoreCase))
if (variable.Name.Equals(variableName, StringComparison.OrdinalIgnoreCase))
{
return new Variable(key, systemVariables[key] as string, VariablesSetType.System);
return new Variable(variable.Name, variable.Values, VariablesSetType.System);
}
}

Expand Down

0 comments on commit 1dde699

Please sign in to comment.