Support for Ctrl-C cancellation in new parser. Added tests for it too.

This commit is contained in:
ridiculousfish
2014-01-02 12:37:50 -08:00
parent 1863be7be4
commit 993148552e
6 changed files with 98 additions and 9 deletions

View File

@@ -173,6 +173,10 @@ parse_execution_context_t::execution_cancellation_reason_t parse_execution_conte
{
return execution_cancellation_exit;
}
else if (parser && parser->cancellation_requested)
{
return execution_cancellation_skip;
}
else if (block && block->loop_status != LOOP_NORMAL)
{
/* Nasty hack - break and continue set the 'skip' flag as well as the loop status flag. */
@@ -1241,12 +1245,14 @@ parse_execution_result_t parse_execution_context_t::run_1_job(const parse_node_t
/* Clean up the job on failure or cancellation */
bool populated_job = (pop_result == parse_execution_success);
if (! populated_job)
if (! populated_job || this->should_cancel_execution(associated_block))
{
delete j;
j = NULL;
populated_job = false;
}
/* Store time it took to 'parse' the command */
if (do_profile)
{