summaryrefslogtreecommitdiff
path: root/Userland/Shell/Shell.cpp
diff options
context:
space:
mode:
authorTheFightingCatfish <seekingblues@gmail.com>2021-07-13 04:00:25 +0800
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-07-13 11:57:11 +0430
commit72e661b542986f4170a6ed9f8412616763e63d60 (patch)
treecbb4a96ac35bd2c0ba497701d4a109d3405717fb /Userland/Shell/Shell.cpp
parent5140994c69bbf8779d2896d6ebd5542f37a59903 (diff)
downloadserenity-72e661b542986f4170a6ed9f8412616763e63d60.zip
Shell: Add unalias builtin
Add shell unalias builtin to remove aliases
Diffstat (limited to 'Userland/Shell/Shell.cpp')
-rw-r--r--Userland/Shell/Shell.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp
index 6f247d6485..487851f0cf 100644
--- a/Userland/Shell/Shell.cpp
+++ b/Userland/Shell/Shell.cpp
@@ -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();