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

Shell: Add the alias builtin and resolve aliases

This follows the other shells in alias resolution, and resolves the
alias only once.
This commit is contained in:
AnotherTest 2020-06-17 18:51:44 +04:30 committed by Andreas Kling
parent a4627f2439
commit 2915dcfcc3
4 changed files with 66 additions and 1 deletions

View file

@ -40,6 +40,7 @@
#include <termios.h>
#define ENUMERATE_SHELL_BUILTINS() \
__ENUMERATE_SHELL_BUILTIN(alias) \
__ENUMERATE_SHELL_BUILTIN(cd) \
__ENUMERATE_SHELL_BUILTIN(cdh) \
__ENUMERATE_SHELL_BUILTIN(pwd) \
@ -73,6 +74,7 @@ public:
static Vector<String> expand_globs(const StringView& path, StringView base);
static Vector<String> expand_globs(Vector<StringView> path_segments, const StringView& base);
String resolve_path(String) const;
String resolve_alias(const String&) const;
RefPtr<AST::Value> lookup_local_variable(const String&);
String local_variable_or(const String&, const String&);
@ -161,6 +163,7 @@ private:
pid_t m_pid { 0 };
HashMap<String, RefPtr<AST::Value>> m_local_variables;
HashMap<String, String> m_aliases;
};
static constexpr bool is_word_character(char c)