diff options
author | dranull <[email protected]> | 2023-12-04 01:35:24 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2023-12-04 01:35:24 +0000 |
commit | 9a9528d09375e6017088af354799ac381b939c1f (patch) | |
tree | 49b71c0c1a4986560953513c6e893693b73af0f0 /src/main.cpp | |
parent | e496b0f250139b572307d048f3189aa6dde72f18 (diff) | |
download | Hyprland-9a9528d09375e6017088af354799ac381b939c1f.tar.gz Hyprland-9a9528d09375e6017088af354799ac381b939c1f.zip |
config: Minor --config improvements, fixes (#4034)
* Follow symlink, only file, absolute path for -c
* Create config file only for default paths
* Skip non-file source= glob results
* Check for absolute path on XDG_CONFIG_HOME
As per spec, all non-absolute paths should be ignored.
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index 27a768ba..0f68c3b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,14 +54,17 @@ int main(int argc, char** argv) { } std::string next_arg = std::next(it)->c_str(); - if (!std::filesystem::exists(next_arg)) { - std::cerr << "[ ERROR ] Config path '" << next_arg << "' doesn't exist!\n"; + if (std::filesystem::is_symlink(next_arg)) + next_arg = std::filesystem::read_symlink(next_arg); + + if (!std::filesystem::is_regular_file(next_arg)) { + std::cerr << "[ ERROR ] Config file '" << next_arg << "' doesn't exist!\n"; help(); return 1; } - configPath = next_arg; + configPath = std::filesystem::weakly_canonical(next_arg); Debug::log(LOG, "User-specified config location: '{}'", configPath); it++; |