Only truncate the programPath if it's followed by an EOL

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4847 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-04-28 21:16:51 +00:00
parent 0f71381685
commit fbf8efefde
1 changed files with 4 additions and 1 deletions

View File

@ -84,7 +84,10 @@ static std::string getProgramPath(const char* programCommand)
if (!programPath.empty())
{
programPath.erase(programPath.find('\n')); // `which' adds a \n which confuses exec()
// `which' adds a \n which confuses exec()
std::string::size_type eol = programPath.find('\n');
if (eol != std::string::npos)
programPath.erase(eol);
debug(LOG_WZ, "Found us at %s", programPath.c_str());
}
else