summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2022-08-20 17:01:53 +0200
committerLinus Groh <mail@linusgroh.de>2022-08-23 19:00:04 +0100
commit39a3775f4870fb16b49fec24aa5fd506b17a0ea9 (patch)
tree2cd49be1c6563988cf74a67599437d57c7014f67 /Userland/Libraries/LibCore
parent61e18c681baacca25dffadeab688730402b6c443 (diff)
downloadserenity-39a3775f4870fb16b49fec24aa5fd506b17a0ea9.zip
Userland: Rely on a single authoritative source for the default `PATH`
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r--Userland/Libraries/LibCore/File.h4
-rw-r--r--Userland/Libraries/LibCore/System.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h
index 6037ff4c99..c331deaf66 100644
--- a/Userland/Libraries/LibCore/File.h
+++ b/Userland/Libraries/LibCore/File.h
@@ -11,6 +11,10 @@
#include <LibCore/IODevice.h>
#include <sys/stat.h>
+// FIXME: Make this a bit prettier.
+#define DEFAULT_PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"
+#define DEFAULT_PATH_SV "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv
+
namespace Core {
class File final : public IODevice {
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp
index e2f277cdcd..8ffcd93870 100644
--- a/Userland/Libraries/LibCore/System.cpp
+++ b/Userland/Libraries/LibCore/System.cpp
@@ -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);