Shell: Don't get stuck on broken state when failing to build command

This commit is contained in:
Bananymous 2025-06-10 08:14:03 +03:00
parent 30d5d85d1d
commit ac22e006a4
1 changed files with 5 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#include "TokenParser.h"
#include <BAN/HashSet.h>
#include <BAN/ScopeGuard.h>
#include <stdio.h>
@ -659,12 +660,13 @@ BAN::ErrorOr<void> TokenParser::run(BAN::Vector<Token>&& tokens)
{
TRY(feed_tokens(BAN::move(tokens)));
BAN::ScopeGuard _([this] {
m_token_stream.clear();
});
auto command_tree = TRY(parse_command_tree());
const auto token_type = peek_token().type();
while (!m_token_stream.empty())
m_token_stream.pop();
if (token_type != Token::Type::EOF_)
return unexpected_token_error(token_type);