- const char *path = getenv("PATH");
- vector<string> dirs = split(path, ITEMSEP);
- for(vector<string>::const_iterator i=dirs.begin(); i!=dirs.end(); ++i)
- if(exists(Path(*i)/argv0))
- {
- exe = realpath(Path(*i)/argv0);
- break;
- }
+ string path = getenv("PATH");
+ if(!path.empty())
+ {
+ for(const string &d: split(path, ITEMSEP))
+ if(exists(Path(d)/argv0))
+ {
+ exe = realpath(Path(d)/argv0);
+ break;
+ }
+ }