From b9bd0ce3a3ba98967bbd173407be1dcba6e889ec Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 19 May 2022 21:08:33 +0200 Subject: [PATCH] Use path_apply_working_directory Using getcwd is naughty here because we want to separate these things in future. --- src/builtins/path.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/builtins/path.cpp b/src/builtins/path.cpp index 5cf368652..117c1de02 100644 --- a/src/builtins/path.cpp +++ b/src/builtins/path.cpp @@ -14,6 +14,8 @@ #include "../common.h" #include "../fallback.h" // IWYU pragma: keep #include "../io.h" +#include "../parser.h" +#include "../path.h" #include "../util.h" #include "../wcstringutil.h" #include "../wgetopt.h" @@ -676,7 +678,8 @@ static int path_resolve(parser_t &parser, io_streams_t &streams, int argc, const wcstring next = *arg; // First add $PWD if we're relative if (!next.empty() && next[0] != L'/') { - next = wgetcwd() + L"/" + next; + // Note pwd can have symlinks, but we are about to resolve it anyway. + next = path_apply_working_directory(*arg, parser.vars().get_pwd_slash()); } auto rest = wbasename(next); while(!next.empty() && next != L"/") {