1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-08 06:37:35 +00:00

Shell: Show descriptions about syntax errors

The description contains an error message and where in the source the
error happened.
This commit is contained in:
AnotherTest 2020-06-28 18:42:57 +04:30 committed by Andreas Kling
parent 034be8e74c
commit d6de2b5828
5 changed files with 90 additions and 43 deletions

View file

@ -325,8 +325,10 @@ int Shell::run_command(const StringView& cmd)
return 0;
if (command->is_syntax_error()) {
// FIXME: Provide descriptive messages for syntax errors.
fprintf(stderr, "Shell: Syntax error in command\n");
auto& error_node = command->syntax_error_node();
auto& position = error_node.position();
fprintf(stderr, "Shell: Syntax error in command: %s\n", error_node.error_text().characters());
fprintf(stderr, "Around '%.*s'\n", (int)min(position.end_offset - position.start_offset, (size_t)10), cmd.characters_without_null_termination() + position.start_offset);
return 1;
}