mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 17:25:07 +00:00
Shell: Parse lists serially, and flatten them only when needed
This allows `((1 2 3) (4 5 6))` to remain nested until we explicitly flatten it out.
This commit is contained in:
parent
9c1da8fca1
commit
95fc7dd03a
4 changed files with 96 additions and 49 deletions
|
@ -361,19 +361,19 @@ int Shell::run_command(const StringView& cmd)
|
|||
if (!command)
|
||||
return 0;
|
||||
|
||||
if (command->is_syntax_error()) {
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef SH_DEBUG
|
||||
dbg() << "Command follows";
|
||||
command->dump(0);
|
||||
#endif
|
||||
|
||||
if (command->is_syntax_error()) {
|
||||
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' at %zu:%zu\n", (int)min(position.end_offset - position.start_offset, (size_t)10), cmd.characters_without_null_termination() + position.start_offset, position.start_offset, position.end_offset);
|
||||
return 1;
|
||||
}
|
||||
|
||||
tcgetattr(0, &termios);
|
||||
|
||||
auto result = command->run(*this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue