From: Mikko Rasa Date: Sun, 22 Aug 2021 09:37:15 +0000 (+0300) Subject: Skip path lookup if PATH is not set X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8bbba6b8cd02c33612fb173e6df48b130407af8f;p=libs%2Fcore.git Skip path lookup if PATH is not set --- diff --git a/source/fs/dir.cpp b/source/fs/dir.cpp index be47162..3811c3f 100644 --- a/source/fs/dir.cpp +++ b/source/fs/dir.cpp @@ -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 dirs = split(path, ITEMSEP); - for(vector::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 dirs = split(path, ITEMSEP); + for(vector::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);