diff options
author | Stella Stamenova <stilis@microsoft.com> | 2018-07-18 15:21:54 +0000 |
---|---|---|
committer | Stella Stamenova <stilis@microsoft.com> | 2018-07-18 15:21:54 +0000 |
commit | 5fae5726d5c7db4e2f364710a3863814c177b442 (patch) | |
tree | 21ece8d033c2ffbbf0ce03252fbb69c6fc5c385a | |
parent | 304bc9a9a72b5a308e7a05ab6e3dccef7d1d867c (diff) |
[windows] Use a well-known path for ComSpec if we fail to retrieve it
Summary: Right now we always try to retrieve ComSpec and if we fail, we give up. This rarely fails, but we can update the logic so that we fail even less frequently. Since there is a well-known path (albeit not always correct), try the path when we failed to retrieve it. Note that on other platforms, we generally just return a well-known path without any checking.
Reviewers: asmith, zturner, labath
Reviewed By: zturner, labath
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D49451
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@337395 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | source/Host/windows/HostInfoWindows.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/source/Host/windows/HostInfoWindows.cpp b/source/Host/windows/HostInfoWindows.cpp index 4b984967b..bd3f74f2e 100644 --- a/source/Host/windows/HostInfoWindows.cpp +++ b/source/Host/windows/HostInfoWindows.cpp @@ -98,9 +98,14 @@ FileSpec HostInfoWindows::GetProgramFileSpec() { } FileSpec HostInfoWindows::GetDefaultShell() { + // Try to retrieve ComSpec from the environment. On the rare occasion + // that it fails, try a well-known path for ComSpec instead. + std::string shell; - GetEnvironmentVar("ComSpec", shell); - return FileSpec(shell, false); + if (GetEnvironmentVar("ComSpec", shell)) + return FileSpec(shell, false); + + return FileSpec("C:\\Windows\\system32\\cmd.exe", false); } bool HostInfoWindows::GetEnvironmentVar(const std::string &var_name, |