env: don't explode when GetShortPathNameW fails (#19284)

It fails inside app containers (!) such as the one used by LocalTests.
This commit is contained in:
Dustin L. Howett 2025-08-26 16:50:32 -05:00 committed by GitHub
parent 9e10436a80
commit 91c9a14a71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -366,12 +366,13 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
if (til::compare_ordinal_insensitive(var, temp) == 0 ||
til::compare_ordinal_insensitive(var, tmp) == 0)
{
return til::details::wil_env::GetShortPathNameW<std::wstring, 256>(value.data());
}
else
{
return std::wstring{ value };
std::wstring shortPath;
if (SUCCEEDED((til::details::wil_env::GetShortPathNameW<std::wstring, 256>(value.data(), shortPath))))
{
return shortPath;
}
}
return std::wstring{ value };
}
static bool is_path_var(std::wstring_view input) noexcept