summaryrefslogtreecommitdiff
path: root/Userland/Shell/Shell.cpp
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2022-08-20 18:31:03 +0200
committerLinus Groh <mail@linusgroh.de>2022-08-23 19:00:04 +0100
commit5f99934dce1e00f5856bd40dca9d5e86e71d625e (patch)
treeaaec591e2fd977714fa200a184c8b5ec701c73e9 /Userland/Shell/Shell.cpp
parent39a3775f4870fb16b49fec24aa5fd506b17a0ea9 (diff)
downloadserenity-5f99934dce1e00f5856bd40dca9d5e86e71d625e.zip
Userland: Consolidate most PATH resolving into a single implementation
We previously had at least three different implementations for resolving executables in the PATH, all of which had slightly different characteristics. Merge those into a single implementation to keep the behaviour consistent, and maybe to make that implementation more configurable in the future.
Diffstat (limited to 'Userland/Shell/Shell.cpp')
-rw-r--r--Userland/Shell/Shell.cpp22
1 files changed, 1 insertions, 21 deletions
diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp
index 6a8fdc3d62..add8fb4977 100644
--- a/Userland/Shell/Shell.cpp
+++ b/Userland/Shell/Shell.cpp
@@ -1338,27 +1338,6 @@ String Shell::unescape_token(StringView token)
return builder.build();
}
-String Shell::find_in_path(StringView program_name)
-{
- String path = getenv("PATH");
- if (!path.is_empty()) {
- auto directories = path.split(':');
- for (auto const& directory : directories) {
- Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots);
- while (programs.has_next()) {
- auto program = programs.next_path();
- auto program_path = String::formatted("{}/{}", directory, program);
- if (access(program_path.characters(), X_OK) != 0)
- continue;
- if (program == program_name)
- return program_path;
- }
- }
- }
-
- return {};
-}
-
void Shell::cache_path()
{
if (!m_is_interactive)
@@ -1387,6 +1366,7 @@ void Shell::cache_path()
cached_path.append({ RunnablePath::Kind::Alias, name });
}
+ // TODO: Can we make this rely on Core::File::resolve_executable_from_environment()?
String path = getenv("PATH");
if (!path.is_empty()) {
auto directories = path.split(':');