diff options
author | Linus Groh <mail@linusgroh.de> | 2020-05-16 19:43:21 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-16 20:57:33 +0200 |
commit | b11c7ad2bad9fc3ef006d4745ef86f78257653ca (patch) | |
tree | 52b560d255e63d91ca417d563eda3f8bd3372134 | |
parent | 5ee79e6657e96ff51394d3fd37b5e5c61cf3c39e (diff) | |
download | serenity-b11c7ad2bad9fc3ef006d4745ef86f78257653ca.zip |
Shell: Properly handle parser syntax errors
In the case of a syntax error the shell parser prints an error message
to stderr and returns an empty Vector<Command> - in that case we
shouldn't try to determine whether or not we can continue parsing but
abort immediately - is_complete() expects that *something* was parsed
successfully.
Fixes #2251.
-rw-r--r-- | Shell/main.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Shell/main.cpp b/Shell/main.cpp index 2f562c0a3d..14c06c9187 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -857,6 +857,9 @@ static ExitCodeOrContinuationRequest run_command(const StringView& cmd) auto commands = Parser(cmd).parse(); + if (!commands.size()) + return 1; + auto needs_more = is_complete(commands); if (needs_more != ExitCodeOrContinuationRequest::Nothing) return needs_more; |