pathut: give $HOME priority over pwd entry

This commit is contained in:
Jean-Francois Dockes 2022-09-11 08:49:08 +02:00
parent 5fc0066a34
commit cadfabc3b1

View File

@ -666,19 +666,16 @@ string path_home()
path_catslash(dir);
return dir;
#else
uid_t uid = getuid();
struct passwd *entry = getpwuid(uid);
if (entry == 0) {
const char *cp = getenv("HOME");
if (cp) {
return cp;
} else {
const char *cp = getenv("HOME");
if (nullptr == cp) {
uid_t uid = getuid();
struct passwd *entry = getpwuid(uid);
if (nullptr == entry) {
return "/";
}
cp = entry->pw_dir;
}
string homedir = entry->pw_dir;
string homedir{cp};
path_catslash(homedir);
return homedir;
#endif