Merge pull request #1361 from CosminCremarenco-Murex/tilde-expansion

Shell expansion rules say that tilde must be replaced with $HOME before calling getpwuid
This commit is contained in:
Günter Obiltschnig 2016-08-27 08:27:38 +02:00 committed by GitHub
commit 63b3e23049

View File

@ -204,7 +204,19 @@ std::string PathImpl::expandImpl(const std::string& path)
++it;
if (it != end && *it == '/')
{
result += homeImpl(); ++it;
const char* homeEnv = getenv("HOME");
if (homeEnv)
{
result += homeEnv;
std::string::size_type resultSize = result.size();
if (resultSize > 0 && result[resultSize - 1] != '/')
result.append("/");
}
else
{
result += homeImpl();
}
++it;
}
else result += '~';
}