]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/dir.cpp
Skip path lookup if PATH is not set
[libs/core.git] / source / fs / dir.cpp
index 8625b783ef464357439833a0d3685175ab40041a..3811c3f447f7f4b0b7677b17be8ce4d0f454f82a 100644 (file)
@@ -37,17 +37,17 @@ const Path &get_bin_dir(const string &argv0)
        if(!(argv0==last_argv0))
        {
                Path exe;
-               if(argv0.find('/')==string::npos)
-               {
-                       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;
-                               }
-               }
+               if(argv0.find(DIRSEP)==string::npos)
+                       if(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;
+                                       }
+                       }
 
                if(exe.empty())
                        exe = realpath(argv0);