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); return system::join(homedrive, homepath);
} }
#else #else
if (struct passwd* const pwd = getpwuid(getuid())) if (const char* const home = getenv("HOME"))
return pwd->pw_dir;
else if (const char* const home = getenv("HOME"))
return home; return home;
else if (struct passwd* const pwd = getpwuid(getuid()))
return pwd->pw_dir;
#endif #endif
return {}; return {};
} }