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

Shell: Add unalias builtin

Add shell unalias builtin to remove aliases
This commit is contained in:
TheFightingCatfish 2021-07-13 04:00:25 +08:00 committed by Ali Mohammad Pur
parent 5140994c69
commit 72e661b542
3 changed files with 57 additions and 3 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2020-2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -1362,6 +1362,19 @@ void Shell::add_entry_to_cache(const String& entry)
cached_path.insert(index, entry);
}
void Shell::remove_entry_from_cache(const String& entry)
{
size_t index { 0 };
auto match = binary_search(
cached_path.span(),
entry,
&index,
[](const auto& a, const auto& b) { return strcmp(a.characters(), b.characters()); });
if (match)
cached_path.remove(index);
}
void Shell::highlight(Line::Editor& editor) const
{
auto line = editor.line();