1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

Shell: Correctly parse quoted filenames in redirection

This commit fixes the (incorrect) behaviour of treating quotes as part
of the redirection filename.

Fixes #1857 :^)
This commit is contained in:
AnotherTest 2020-04-30 05:26:16 +04:30 committed by Andreas Kling
parent fc34123a54
commit fb63b84c78
2 changed files with 73 additions and 23 deletions

View file

@ -67,7 +67,10 @@ public:
Vector<Command> parse();
private:
enum class AllowEmptyToken { No, Yes };
enum class AllowEmptyToken {
No,
Yes,
};
void commit_token(AllowEmptyToken = AllowEmptyToken::No);
void commit_subcommand();
void commit_command();
@ -82,7 +85,22 @@ private:
InWriteAppendOrRedirectionPath,
InRedirectionPath,
};
State m_state { Free };
State state() const { return m_state_stack.last(); }
void pop_state()
{
m_state_stack.take_last();
}
void push_state(State state)
{
m_state_stack.append(state);
}
bool in_state(State) const;
Vector<State> m_state_stack { Free };
String m_input;
Vector<Command> m_commands;