diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-04-03 07:56:04 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-04-03 08:17:16 +0200 |
commit | cd6c3ea1c3ca853fc38da4fa5fd62545c31aa92d (patch) | |
tree | 57d7956ab19a756cfcf8fdd65aa8fb6e511133c5 /src/util.cc | |
parent | 494401c0e0d29018f0ac53e91a3481d12e427ea6 (diff) |
Diffstat (limited to 'src/util.cc')
-rw-r--r-- | src/util.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/util.cc b/src/util.cc index 3517e0b..a4abd23 100644 --- a/src/util.cc +++ b/src/util.cc @@ -8,6 +8,7 @@ #include <algorithm> #include <sstream> #include <cctype> +#include <cstdlib> std::string to_lower(std::string str) { @@ -117,8 +118,18 @@ std::string esc(const std::string& in) return out; } -std::vector<std::string> get_paths(const std::string& path_env) +std::vector<std::string> get_paths(const std::string& path_env_) { + std::string path_env; + if(!path_env_.empty()) + { + path_env = path_env_; + } + else + { + get_env("PATH", path_env); + } + std::vector<std::string> paths; #ifdef _WIN32 @@ -285,3 +296,14 @@ std::vector<std::string> argsplit(const std::string& str) } return tokens; } + +bool get_env(std::string_view name, std::string& value) +{ + auto var = getenv(name.data()); + if(var) + { + value = var; + return true; + } + return false; +} |