From 1d08cab9ab11c03869f3e02b1b1c73f60272599f Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Tue, 4 Aug 2020 14:23:23 +0430 Subject: Shell: Correct FdRedirection inheriting from two RefCounted bases Also add missing calls to `adopt()`. --- Shell/Shell.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Shell/Shell.cpp') diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index 25ee4b5fd2..cf6c66a9f7 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -287,8 +287,8 @@ Vector Shell::expand_aliases(Vector initial_commands auto* ast = static_cast(subcommand_ast.ptr()); subcommand_ast = ast->command(); } - AST::Node& substitute = *new AST::Join(subcommand_ast->position(), subcommand_ast, *new AST::CommandLiteral(subcommand_ast->position(), command)); - for (auto& subst_command : substitute.run(*this)->resolve_as_commands(*this)) { + RefPtr substitute = adopt(*new AST::Join(subcommand_ast->position(), subcommand_ast, 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); else @@ -596,8 +596,7 @@ Vector> Shell::run_commands(Vector& commands) auto path_redir = (const AST::PathRedirection*)redir.ptr(); dbg() << "redir path " << (int)path_redir->direction << " " << path_redir->path << " <-> " << path_redir->fd; } else if (redir->is_fd_redirection()) { - auto fd_redir = (const AST::FdRedirection*)redir.ptr(); - dbg() << "redir fd " << fd_redir->source_fd << " -> " << fd_redir->dest_fd; + dbg() << "redir fd " << redir->source_fd << " -> " << redir->dest_fd; } else if (redir->is_close_redirection()) { auto close_redir = (const AST::CloseRedirection*)redir.ptr(); dbg() << "close fd " << close_redir->fd; -- cgit v1.2.3