mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:47:34 +00:00
parent
8ab601f9e1
commit
173effc88d
1 changed files with 26 additions and 19 deletions
|
@ -631,10 +631,20 @@ void Shell::cache_path()
|
||||||
if (!cached_path.is_empty())
|
if (!cached_path.is_empty())
|
||||||
cached_path.clear_with_capacity();
|
cached_path.clear_with_capacity();
|
||||||
|
|
||||||
String path = getenv("PATH");
|
// Add shell builtins to the cache.
|
||||||
if (path.is_empty())
|
for (const auto& builtin_name : builtin_names)
|
||||||
return;
|
cached_path.append(escape_token(builtin_name));
|
||||||
|
|
||||||
|
// Add aliases to the cache.
|
||||||
|
for (const auto& alias : m_aliases) {
|
||||||
|
auto name = escape_token(alias.key);
|
||||||
|
if (cached_path.contains_slow(name))
|
||||||
|
continue;
|
||||||
|
cached_path.append(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
String path = getenv("PATH");
|
||||||
|
if (!path.is_empty()) {
|
||||||
auto directories = path.split(':');
|
auto directories = path.split(':');
|
||||||
for (const auto& directory : directories) {
|
for (const auto& directory : directories) {
|
||||||
Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots);
|
Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots);
|
||||||
|
@ -648,10 +658,7 @@ void Shell::cache_path()
|
||||||
cached_path.append(escaped_name);
|
cached_path.append(escaped_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// add shell builtins to the cache
|
|
||||||
for (const auto& builtin_name : builtin_names)
|
|
||||||
cached_path.append(escape_token(builtin_name));
|
|
||||||
|
|
||||||
quick_sort(cached_path);
|
quick_sort(cached_path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue