diff --git a/src/parser.cpp b/src/parser.cpp index e44744e24..92c33b706 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -644,22 +644,18 @@ int parser_t::eval(wcstring cmd, const io_chain_t &io, enum block_type_t block_t fwprintf(stderr, L"%ls\n", backtrace_and_desc.c_str()); return 1; } - return this->eval(ps, io, block_type); + this->eval(ps, io, block_type); + return 0; } -int parser_t::eval(parsed_source_ref_t ps, const io_chain_t &io, enum block_type_t block_type) { +void parser_t::eval(parsed_source_ref_t ps, const io_chain_t &io, enum block_type_t block_type) { CHECK_BLOCK(1); assert(block_type == TOP || block_type == SUBST); - - if (ps->tree.empty()) { - return 0; + if (!ps->tree.empty()) { + // Execute the first node. + tnode_t start{&ps->tree, &ps->tree.front()}; + this->eval_node(ps, start, io, block_type); } - - // Execute the first node. - tnode_t start{&ps->tree, &ps->tree.front()}; - this->eval_node(ps, start, io, block_type); - - return 0; } template diff --git a/src/parser.h b/src/parser.h index 289f8b8ae..35ca8922f 100644 --- a/src/parser.h +++ b/src/parser.h @@ -238,11 +238,11 @@ class parser_t { /// \param io io redirections to perform on all started jobs /// \param block_type The type of block to push on the block stack /// - /// \return 0 on success, 1 otherwise + /// \return 0 on success, 1 on a parse error. int eval(wcstring cmd, const io_chain_t &io, enum block_type_t block_type); /// Evaluate the parsed source ps. - int eval(parsed_source_ref_t ps, const io_chain_t &io, enum block_type_t block_type); + void eval(parsed_source_ref_t ps, const io_chain_t &io, enum block_type_t block_type); /// Evaluates a node. /// The node type must be grammar::statement or grammar::job_list.