in src/PowerShell/Utilities/SharedUtilities.cs [58:107]
private static string GetUserHomeDirOnUnix()
{
if (IsWindowsPlatform())
{
throw new NotSupportedException();
}
if (!string.IsNullOrEmpty(s_homeEnvVar))
{
return s_homeEnvVar;
}
string username = null;
if (!string.IsNullOrEmpty(s_lognameEnvVar))
{
username = s_lognameEnvVar;
}
else if (!string.IsNullOrEmpty(s_userEnvVar))
{
username = s_userEnvVar;
}
else if (!string.IsNullOrEmpty(s_lNameEnvVar))
{
username = s_lNameEnvVar;
}
else if (!string.IsNullOrEmpty(s_usernameEnvVar))
{
username = s_usernameEnvVar;
}
if (IsMacPlatform())
{
return !string.IsNullOrEmpty(username) ? Path.Combine("/Users", username) : null;
}
else if (IsLinuxPlatform())
{
if (LinuxNativeMethods.getuid() == LinuxNativeMethods.RootUserId)
{
return "/root";
}
else
{
return !string.IsNullOrEmpty(username) ? Path.Combine("/home", username) : null;
}
}
else
{
throw new NotSupportedException();
}
}