diff --git a/Shell/Parser.cpp b/Shell/Parser.cpp index 382ce15a11..2280ef4057 100644 --- a/Shell/Parser.cpp +++ b/Shell/Parser.cpp @@ -1,6 +1,7 @@ #include "Parser.h" #include #include +#include void Parser::commit_token() { @@ -102,6 +103,28 @@ Vector Parser::parse() m_state = State::InDoubleQuotes; break; } + if (isdigit(ch)) { + if (i != m_input.length() - 1) { + char next_ch = m_input.characters()[i + 1]; + if (next_ch == '>') { + commit_token(); + begin_redirect_write(ch - '0'); + ++i; + + // Search for another > for append. + m_state = State::InWriteAppendOrRedirectionPath; + break; + } + if (next_ch == '<') { + commit_token(); + begin_redirect_read(ch - '0'); + ++i; + + m_state = State::InRedirectionPath; + break; + } + } + } m_token.append(ch); break; case State::InWriteAppendOrRedirectionPath: