From c632307eaa4fdd8ac09bb1a9bf031101b1e0b6a2 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 28 Dec 2013 16:33:26 -0800 Subject: [PATCH] Make eval_node_at_offset return an error indication instead of the exit status of the last command --- parse_execution.cpp | 16 +++++++++++----- parse_execution.h | 2 +- parser.cpp | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/parse_execution.cpp b/parse_execution.cpp index 72d4452cf..4201c288b 100644 --- a/parse_execution.cpp +++ b/parse_execution.cpp @@ -1013,25 +1013,25 @@ int parse_execution_context_t::eval_node_at_offset(node_offset_t offset, const b node.type == symbol_if_statement || node.type == symbol_switch_statement); - int ret = 1; + int status = 1; switch (node.type) { case symbol_job_list: /* We should only get a job list if it's the very first node. This is because this is the entry point for both top-level execution (the first node) and INTERNAL_BLOCK_NODE execution (which does block statements, but never job lists) */ assert(offset == 0); - ret = this->run_job_list(node, associated_block); + status = this->run_job_list(node, associated_block); break; case symbol_block_statement: - ret = this->run_block_statement(node); + status = this->run_block_statement(node); break; case symbol_if_statement: - ret = this->run_if_statement(node); + status = this->run_if_statement(node); break; case symbol_switch_statement: - ret = this->run_switch_statement(node); + status = this->run_switch_statement(node); break; default: @@ -1040,5 +1040,11 @@ int parse_execution_context_t::eval_node_at_offset(node_offset_t offset, const b PARSER_DIE(); break; } + + proc_set_last_status(status); + + /* Argh */ + int ret = errors.empty() ? 0 : 1; + errors.clear(); return ret; } diff --git a/parse_execution.h b/parse_execution.h index 901f79811..8d89158bd 100644 --- a/parse_execution.h +++ b/parse_execution.h @@ -71,7 +71,7 @@ class parse_execution_context_t public: parse_execution_context_t(const parse_node_tree_t &t, const wcstring &s, parser_t *p); - /* Start executing at the given node offset, returning the exit status of the last process. */ + /* Start executing at the given node offset. Returns 0 if there was no error, 1 if there was an error */ int eval_node_at_offset(node_offset_t offset, const block_t *associated_block, const io_chain_t &io); }; diff --git a/parser.cpp b/parser.cpp index c3b9578a6..c60527814 100644 --- a/parser.cpp +++ b/parser.cpp @@ -2625,7 +2625,7 @@ int parser_t::eval_new_parser(const wcstring &cmd, const io_chain_t &io, enum bl execution_contexts.pop_back(); delete ctx; - return result; + return 0; } int parser_t::eval_block_node(node_offset_t node_idx, const io_chain_t &io, enum block_type_t block_type)