status: Realpath the executable path

get_executable_path says: "This needs to be realpath'd"

So how about we do that? The only other place we use it is fish.cpp,
and we realpath it there already.

See #9085
This commit is contained in:
Fabian Boehm 2022-07-24 12:36:32 +02:00
parent 2cb0cada86
commit 4f1c62ff43

View File

@ -4,6 +4,7 @@
#include "status.h" #include "status.h"
#include <cstddef> #include <cstddef>
#include <cstring>
#include <cwchar> #include <cwchar>
#include <string> #include <string>
@ -453,9 +454,14 @@ maybe_t<int> builtin_status(parser_t &parser, io_streams_t &streams, const wchar
break; break;
} }
case STATUS_FISH_PATH: { case STATUS_FISH_PATH: {
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd) CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd);
streams.out.append(str2wcstring(get_executable_path("fish"))); auto real = wrealpath(str2wcstring(get_executable_path("fish")));
streams.out.push_back(L'\n'); if (real) {
streams.out.append(*real);
streams.out.push_back(L'\n');
} else {
streams.err.append_format(L"realpath failed: '%s'\n", cmd, std::strerror(errno));
}
break; break;
} }
} }