mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-09 03:08:31 +01:00
Shell expansion rules say that tilde must be replaced with HOME if it exists and only after that we can look at getpwuid
This commit is contained in:
parent
bb456d342a
commit
9d81f54067
@ -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 += '~';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user