Make eval_node_at_offset return an error indication instead of the exit

status of the last command
This commit is contained in:
ridiculousfish 2013-12-28 16:33:26 -08:00
parent 0f9de11a67
commit c632307eaa
3 changed files with 13 additions and 7 deletions

View file

@ -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_if_statement ||
node.type == symbol_switch_statement); node.type == symbol_switch_statement);
int ret = 1; int status = 1;
switch (node.type) switch (node.type)
{ {
case symbol_job_list: 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) */ /* 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); assert(offset == 0);
ret = this->run_job_list(node, associated_block); status = this->run_job_list(node, associated_block);
break; break;
case symbol_block_statement: case symbol_block_statement:
ret = this->run_block_statement(node); status = this->run_block_statement(node);
break; break;
case symbol_if_statement: case symbol_if_statement:
ret = this->run_if_statement(node); status = this->run_if_statement(node);
break; break;
case symbol_switch_statement: case symbol_switch_statement:
ret = this->run_switch_statement(node); status = this->run_switch_statement(node);
break; break;
default: default:
@ -1040,5 +1040,11 @@ int parse_execution_context_t::eval_node_at_offset(node_offset_t offset, const b
PARSER_DIE(); PARSER_DIE();
break; break;
} }
proc_set_last_status(status);
/* Argh */
int ret = errors.empty() ? 0 : 1;
errors.clear();
return ret; return ret;
} }

View file

@ -71,7 +71,7 @@ class parse_execution_context_t
public: public:
parse_execution_context_t(const parse_node_tree_t &t, const wcstring &s, parser_t *p); 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); int eval_node_at_offset(node_offset_t offset, const block_t *associated_block, const io_chain_t &io);
}; };

View file

@ -2625,7 +2625,7 @@ int parser_t::eval_new_parser(const wcstring &cmd, const io_chain_t &io, enum bl
execution_contexts.pop_back(); execution_contexts.pop_back();
delete ctx; 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) int parser_t::eval_block_node(node_offset_t node_idx, const io_chain_t &io, enum block_type_t block_type)