diff --git a/Shell/Parser.cpp b/Shell/Parser.cpp index e08aa054f27..9fcc1a2683d 100644 --- a/Shell/Parser.cpp +++ b/Shell/Parser.cpp @@ -29,9 +29,9 @@ #include #include -void Parser::commit_token() +void Parser::commit_token(AllowEmptyToken allow_empty) { - if (m_token.is_empty()) + if (allow_empty == AllowEmptyToken::No && m_token.is_empty()) return; if (m_state == InRedirectionPath) { m_redirections.last().path = String::copy(m_token); @@ -239,7 +239,7 @@ Vector Parser::parse() break; case State::InSingleQuotes: if (ch == '\'') { - commit_token(); + commit_token(AllowEmptyToken::Yes); m_state = State::Free; break; } @@ -247,7 +247,7 @@ Vector Parser::parse() break; case State::InDoubleQuotes: if (ch == '\"') { - commit_token(); + commit_token(AllowEmptyToken::Yes); m_state = State::Free; break; } diff --git a/Shell/Parser.h b/Shell/Parser.h index fb516d95b18..06950e02ff7 100644 --- a/Shell/Parser.h +++ b/Shell/Parser.h @@ -67,7 +67,8 @@ public: Vector parse(); private: - void commit_token(); + enum class AllowEmptyToken { No, Yes }; + void commit_token(AllowEmptyToken = AllowEmptyToken::No); void commit_subcommand(); void commit_command(); void do_pipe();