From cc632d6ae95bdf3ebde068358397666b6a1b3b68 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 12 Jul 2022 20:53:57 +0200 Subject: [PATCH] realpath: Use the parser's working dir Future proofing, similar to what we do in `path resolve`. --- src/builtins/realpath.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/builtins/realpath.cpp b/src/builtins/realpath.cpp index 9ed61bafe..2637b84e5 100644 --- a/src/builtins/realpath.cpp +++ b/src/builtins/realpath.cpp @@ -12,6 +12,8 @@ #include "../common.h" #include "../fallback.h" // IWYU pragma: keep #include "../io.h" +#include "../parser.h" +#include "../path.h" #include "../wcstringutil.h" #include "../wgetopt.h" #include "../wutil.h" // IWYU pragma: keep @@ -99,7 +101,7 @@ maybe_t builtin_realpath(parser_t &parser, io_streams_t &streams, const wch return STATUS_CMD_ERROR; } } else { - wcstring absolute_arg = string_prefixes_string(L"/", arg) ? arg : wgetcwd() + L"/" + arg; + wcstring absolute_arg = string_prefixes_string(L"/", arg) ? arg : path_apply_working_directory(arg, parser.vars().get_pwd_slash()); streams.out.append(normalize_path(absolute_arg, /* allow leading double slashes */ false)); }