Prefer HOME env var before trying getpwuid

This commit is contained in:
falkTX 2021-11-12 16:13:52 +00:00
parent 036c8a7c26
commit 0df3db43c6

View file

@ -121,10 +121,10 @@ static std::string homeDir()
return system::join(homedrive, homepath);
}
#else
if (struct passwd* const pwd = getpwuid(getuid()))
return pwd->pw_dir;
else if (const char* const home = getenv("HOME"))
if (const char* const home = getenv("HOME"))
return home;
else if (struct passwd* const pwd = getpwuid(getuid()))
return pwd->pw_dir;
#endif
return {};
}