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

Shell: Use NonnullRefPtr to store non-null subnodes

Also replaces null-is-invalid nodes with syntax error nodes.
This commit is contained in:
AnotherTest 2020-09-16 05:07:14 +04:30 committed by Andreas Kling
parent 2d7aaab897
commit 51e598cf0b
4 changed files with 162 additions and 144 deletions

View file

@ -292,7 +292,9 @@ Vector<AST::Command> Shell::expand_aliases(Vector<AST::Command> initial_commands
auto* ast = static_cast<AST::Execute*>(subcommand_ast.ptr());
subcommand_ast = ast->command();
}
RefPtr<AST::Node> substitute = adopt(*new AST::Join(subcommand_ast->position(), subcommand_ast, adopt(*new AST::CommandLiteral(subcommand_ast->position(), command))));
NonnullRefPtr<AST::Node> substitute = adopt(*new AST::Join(subcommand_ast->position(),
subcommand_ast.release_nonnull(),
adopt(*new AST::CommandLiteral(subcommand_ast->position(), command))));
for (auto& subst_command : substitute->run(*this)->resolve_as_commands(*this)) {
if (!subst_command.argv.is_empty() && subst_command.argv.first() == argv0) // Disallow an alias resolving to itself.
commands.append(subst_command);