summaryrefslogtreecommitdiff
path: root/Shell/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Shell/Parser.cpp')
-rw-r--r--Shell/Parser.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/Shell/Parser.cpp b/Shell/Parser.cpp
index dd85237fda..31ce752f9b 100644
--- a/Shell/Parser.cpp
+++ b/Shell/Parser.cpp
@@ -22,6 +22,13 @@ void Parser::commit_subcommand()
m_subcommands.append({ move(m_tokens), move(m_redirections), {} });
}
+void Parser::commit_command()
+{
+ if (m_subcommands.is_empty())
+ return;
+ m_commands.append({ move(m_subcommands) });
+}
+
void Parser::do_pipe()
{
m_redirections.append({ Redirection::Pipe, STDOUT_FILENO });
@@ -38,7 +45,7 @@ void Parser::begin_redirect_write(int fd)
m_redirections.append({ Redirection::FileWrite, fd });
}
-Vector<Subcommand> Parser::parse()
+Vector<Command> Parser::parse()
{
for (int i = 0; i < m_input.length(); ++i) {
char ch = m_input.characters()[i];
@@ -48,6 +55,12 @@ Vector<Subcommand> Parser::parse()
commit_token();
break;
}
+ if (ch == ';') {
+ commit_token();
+ commit_subcommand();
+ commit_command();
+ break;
+ }
if (ch == '|') {
commit_token();
if (m_tokens.is_empty()) {
@@ -140,6 +153,7 @@ Vector<Subcommand> Parser::parse()
}
commit_token();
commit_subcommand();
+ commit_command();
if (!m_subcommands.is_empty()) {
for (auto& redirection : m_subcommands.last().redirections) {
@@ -150,5 +164,5 @@ Vector<Subcommand> Parser::parse()
}
}
- return move(m_subcommands);
+ return move(m_commands);
}