From 91c9a14a710af7048d7d8c3d74b1d2bc2744bc97 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 26 Aug 2025 16:50:32 -0500 Subject: [PATCH] env: don't explode when GetShortPathNameW fails (#19284) It fails inside app containers (!) such as the one used by LocalTests. --- src/inc/til/env.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/inc/til/env.h b/src/inc/til/env.h index e41ae645dd..9e0eebf61a 100644 --- a/src/inc/til/env.h +++ b/src/inc/til/env.h @@ -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(value.data()); - } - else - { - return std::wstring{ value }; + std::wstring shortPath; + if (SUCCEEDED((til::details::wil_env::GetShortPathNameW(value.data(), shortPath)))) + { + return shortPath; + } } + return std::wstring{ value }; } static bool is_path_var(std::wstring_view input) noexcept