mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-24 10:59:23 +01:00
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:
commit
63b3e23049
@ -204,7 +204,19 @@ std::string PathImpl::expandImpl(const std::string& path)
|
|||||||
++it;
|
++it;
|
||||||
if (it != end && *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 += '~';
|
else result += '~';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user