diff --git a/CMakeLists.txt b/CMakeLists.txt index ea33e8bf..63767855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ set(SOURCES_CONTROL set(SOURCES_COMMON src/common/Connection.cpp src/common/Connection.h + src/common/expand_path.h src/common/Filter.h src/common/Host.cpp src/common/Host.h diff --git a/src/common/expand_path.h b/src/common/expand_path.h new file mode 100644 index 00000000..3a57b557 --- /dev/null +++ b/src/common/expand_path.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +#if !defined(_WIN32) + +#include + +inline std::string expand_path(std::string string) { + auto exp_result = wordexp_t{ }; + wordexp(string.c_str(), &exp_result, 0); + string = exp_result.we_wordv[0]; + wordfree(&exp_result); + return string; +} + +#else // !_WIN32 + +inline std::string expand_path(std::string string) { + return string; +} + +#endif // !_WIN32 diff --git a/src/config/ParseConfig.cpp b/src/config/ParseConfig.cpp index 81dae7e9..70ada17e 100644 --- a/src/config/ParseConfig.cpp +++ b/src/config/ParseConfig.cpp @@ -3,6 +3,7 @@ #include "string_iteration.h" #include "runtime/Key.h" #include "common/parse_regex.h" +#include "common/expand_path.h" #include #include #include @@ -260,7 +261,7 @@ void ParseConfig::parse_directive(It* it, const It end) { const auto ident = read_ident(it, end); skip_space_and_comments(it, end); if (ident == "include") { - const auto filename = read_value(it, end); + const auto filename = expand_path(read_value(it, end)); auto is = std::ifstream(filename); if (!is.good()) error("Opening include file '" + filename + "' failed");