1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:48:11 +00:00

Userland: Rely on a single authoritative source for the default PATH

This commit is contained in:
Tim Schumacher 2022-08-20 17:01:53 +02:00 committed by Linus Groh
parent 61e18c681b
commit 39a3775f48
7 changed files with 14 additions and 7 deletions

View file

@ -958,7 +958,7 @@ ErrorOr<String> find_file_in_path(StringView filename)
auto const* path_ptr = getenv("PATH");
StringView path { path_ptr, strlen(path_ptr) };
if (path.is_empty())
path = "/bin:/usr/bin"sv;
path = DEFAULT_PATH_SV;
auto parts = path.split_view(':');
for (auto& part : parts) {
auto candidate = String::formatted("{}/{}", part, filename);
@ -1043,7 +1043,7 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
ScopedValueRollback errno_rollback(errno);
String path = getenv("PATH");
if (path.is_empty())
path = "/bin:/usr/bin";
path = DEFAULT_PATH;
auto parts = path.split(':');
for (auto& part : parts) {
auto candidate = String::formatted("{}/{}", part, filename);