Fix a few errors identified by testing new parser

This commit is contained in:
ridiculousfish 2013-12-26 13:36:43 -08:00
parent 6536ffe178
commit c1a13ae8bc
2 changed files with 25 additions and 0 deletions

View file

@ -545,6 +545,14 @@ int parse_execution_context_t::run_1_job(const parse_node_t &job_node)
/* Populate the job. This may fail for reasons like command_not_found */
bool process_errored = ! this->populate_job_from_job_node(j, job_node);
/* If we errored, we have to clean up the job */
if (process_errored)
{
assert(parser->current_block()->job == j);
parser->current_block()->job = NULL;
job_free(j);
}
/* Store time it took to 'parse' the command */
if (do_profile)
{

View file

@ -2615,6 +2615,8 @@ int parser_t::eval_new_parser(const wcstring &cmd, const io_chain_t &io, enum bl
execution_contexts.push_back(ctx);
/* Start it up */
const block_t * const start_current_block = current_block();
this->push_block(new scope_block_t(block_type));
int result = ctx->eval_top_level_job_list();
/* Clean up the execution context stack */
@ -2622,6 +2624,21 @@ int parser_t::eval_new_parser(const wcstring &cmd, const io_chain_t &io, enum bl
execution_contexts.pop_back();
delete ctx;
/* Clean up the block stack */
this->pop_block();
while (start_current_block != current_block())
{
if (current_block() == NULL)
{
debug(0,
_(L"End of block mismatch. Program terminating."));
bugreport();
FATAL_EXIT();
break;
}
this->pop_block();
}
/* Reap again */
job_reap(0);