From ec199aa804683939fe0117c02d297a0df6be3e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20=C5=A0vagelj?= Date: Fri, 15 Nov 2024 23:29:41 +0100 Subject: [PATCH] Simplify to_real_path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tin Å vagelj --- src/common.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/common.cc b/src/common.cc index d9ce8fb48..ac30edb7e 100644 --- a/src/common.cc +++ b/src/common.cc @@ -141,16 +141,10 @@ double get_time() { /// - `$HOME/a/b/../c/../../conky` -> `/home/conky_user/conky` std::filesystem::path to_real_path(const std::filesystem::path &source) { try { - std::string input; + std::string input = source.string(); if (source.string().compare(0, 1, "~") == 0) { const char *home = std::getenv("HOME"); - if (home) { - input = std::string(home) + source.string().substr(1); - } else { - input = source.string(); // Fallback if HOME is not set - } - } else { - input = source.string(); + if (home) { input = std::string(home) + source.string().substr(1); } } std::string expanded = variable_substitute(input); std::filesystem::path absolute = std::filesystem::absolute(expanded);