mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Make eval_node_at_offset return an error indication instead of the exit
status of the last command
This commit is contained in:
parent
0f9de11a67
commit
c632307eaa
3 changed files with 13 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue