Skip to content

Commit

Permalink
gh-468: Fix for environment reload from registry (expand variables in…
Browse files Browse the repository at this point in the history
… PATH).

  The problem was with `PATH` variable, it contains substitutes `%SystemRoot%`,
  but they were not expanded during environment refresh.
  • Loading branch information
Maximus5 committed Jul 11, 2020
1 parent e80a39b commit 3ac5410
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ConEmu/SystemEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ bool SystemEnvironment::SysEnvValueCallback(HKEY hk, LPCWSTR pszName, DWORD dwTy
data.name = pszName;
if (key == L"path")
{
// concatenate "%PATH%" as "USER;SYSTEM"
// it stored in registry as REG_SZ, but we need to expand it!
data.expandable = true;
// concatenate "%PATH%" as "SYSTEM;USER"
if (!reg_data.IsEmpty())
data.data = reg_data.c_str(L"")
+ std::wstring(data.data.empty() ? L"" : L";")
+ data.data;
{
const std::wstring append_data(reg_data.c_str(L""));
_ASSERTE(!append_data.empty());
if (!data.data.empty() && (data.data.back() != L';'))
data.data.append(L";");
data.data.append(append_data);
}
}
else
{
Expand Down

0 comments on commit 3ac5410

Please sign in to comment.