]> git.tdb.fi Git - libs/core.git/commitdiff
Skip path lookup if PATH is not set
authorMikko Rasa <tdb@tdb.fi>
Sun, 22 Aug 2021 09:37:15 +0000 (12:37 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 22 Aug 2021 09:37:15 +0000 (12:37 +0300)
source/fs/dir.cpp

index be471628ceac105de600b341107ff2064a0bc090..3811c3f447f7f4b0b7677b17be8ce4d0f454f82a 100644 (file)
@@ -38,16 +38,16 @@ const Path &get_bin_dir(const string &argv0)
        {
                Path exe;
                if(argv0.find(DIRSEP)==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(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);