mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
Shell: Start implementing a POSIX-compliant parser
The parser is still very much a work-in-progress, but it can currently parse most of the basic bits, the only *completely* unimplemented things in the parser are: - heredocs (io_here) - alias expansion - arithmetic expansion There are a whole suite of bugs, and syntax highlighting is unreliable at best. For now, this is not attached anywhere, a future commit will enable it for /bin/sh or a `Shell --posix` invocation.
This commit is contained in:
parent
2dc1682274
commit
2a276c86d4
Notes:
sideshowbarker
2024-07-17 06:09:44 +09:00
Author: https://github.com/alimpfard
Commit: 2a276c86d4
Pull-request: https://github.com/SerenityOS/serenity/pull/17437
Reviewed-by: https://github.com/kleinesfilmroellchen
Reviewed-by: https://github.com/linusg
14 changed files with 3444 additions and 28 deletions
|
@ -61,16 +61,26 @@
|
|||
__ENUMERATE_SHELL_OPTION(verbose, false, "Announce every command that is about to be executed") \
|
||||
__ENUMERATE_SHELL_OPTION(invoke_program_for_autocomplete, false, "Attempt to use the program being completed itself for autocompletion via --complete")
|
||||
|
||||
#define ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS() \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(concat_lists) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(length) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(length_across) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(remove_suffix) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(remove_prefix) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(regex_replace) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(filter_glob) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(split) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(join)
|
||||
#define ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS() \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(concat_lists) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(length) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(length_across) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(remove_suffix) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(remove_prefix) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(regex_replace) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(filter_glob) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(split) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(join) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(value_or_default) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(assign_default) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(error_if_empty) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(null_or_alternative) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(defined_value_or_default) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(assign_defined_default) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(error_if_unset) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(null_if_unset_or_alternative) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(length_of_variable) \
|
||||
__ENUMERATE_SHELL_IMMEDIATE_FUNCTION(reexpand)
|
||||
|
||||
namespace Shell {
|
||||
|
||||
|
@ -376,10 +386,12 @@ public:
|
|||
#undef __ENUMERATE_SHELL_OPTION
|
||||
|
||||
private:
|
||||
Shell(Line::Editor&, bool attempt_interactive);
|
||||
Shell(Line::Editor&, bool attempt_interactive, bool posix_mode = false);
|
||||
Shell();
|
||||
virtual ~Shell() override;
|
||||
|
||||
RefPtr<AST::Node> parse(StringView, bool interactive = false, bool as_command = true) const;
|
||||
|
||||
void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
bool is_allowed_to_modify_termios(const AST::Command&) const;
|
||||
|
@ -450,6 +462,7 @@ private:
|
|||
bool m_is_interactive { true };
|
||||
bool m_is_subshell { false };
|
||||
bool m_should_reinstall_signal_handlers { true };
|
||||
bool m_in_posix_mode { false };
|
||||
|
||||
ShellError m_error { ShellError::None };
|
||||
DeprecatedString m_error_description;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue