diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-06-28 18:42:57 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-05 15:43:14 +0200 |
commit | d6de2b582860c3e533c4420ce6249c7f9b753e87 (patch) | |
tree | e9931ace61442489d7ca727552a4b6815ed86f5e /Shell/Shell.cpp | |
parent | 034be8e74c946f2820ab7a31f04d168574456f7c (diff) | |
download | serenity-d6de2b582860c3e533c4420ce6249c7f9b753e87.zip |
Shell: Show descriptions about syntax errors
The description contains an error message and where in the source the
error happened.
Diffstat (limited to 'Shell/Shell.cpp')
-rw-r--r-- | Shell/Shell.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index 3bfbb0c84e..b04d134774 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -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; } |