1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 09:17:35 +00:00

Shell: Add a 'kill' builtin that wraps the system's own

Fixes #6578.
This commit is contained in:
Ali Mohammad Pur 2021-04-23 19:09:13 +04:30 committed by Linus Groh
parent 95055d3a38
commit 0d2602c900
3 changed files with 62 additions and 1 deletions

View file

@ -1194,6 +1194,27 @@ String Shell::unescape_token(const String& token)
return builder.build();
}
String Shell::find_in_path(const StringView& program_name)
{
String path = getenv("PATH");
if (!path.is_empty()) {
auto directories = path.split(':');
for (const auto& 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)