From 8bbba6b8cd02c33612fb173e6df48b130407af8f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 22 Aug 2021 12:37:15 +0300 Subject: [PATCH] Skip path lookup if PATH is not set --- source/fs/dir.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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); -- 2.43.0