diff --git a/builtin.c b/builtin.c index ca057ed17..4e30a51f9 100644 --- a/builtin.c +++ b/builtin.c @@ -2843,6 +2843,18 @@ static int builtin_break_continue( wchar_t **argv ) return STATUS_BUILTIN_OK; } +static int builtin_breakpoint( wchar_t **argv ) +{ + parser_push_block( BREAKPOINT ); + + reader_read( 0 ); + + parser_pop_block(); + + return proc_get_last_status(); +} + + /** Function for handling the \c return builtin */ @@ -3108,6 +3120,10 @@ const static builtin_data_t builtin_data[]= L"begin", &builtin_begin, N_( L"Create a block of code" ) } , + { + L"breakpoint", &builtin_breakpoint, N_( L"Temporarily halt execution and launch a new prompt" ) + } + , /* Builtins that are handled directly by the parser. They are diff --git a/parser.c b/parser.c index 9707bab80..2b887f81c 100644 --- a/parser.c +++ b/parser.c @@ -188,6 +188,12 @@ The fish parser. Contains functions for parsing and evaluating code. */ #define FOR_BLOCK N_( L"'for' block" ) +/** + Breakpoint block +*/ +#define BREAKPOINT_BLOCK N_( L"Block created by breakpoint" ) + + /** If block description @@ -331,7 +337,11 @@ const static struct block_lookup_entry block_lookup[]= } , { - 0,0,0 + BREAKPOINT, L"breakpoint", BREAKPOINT_BLOCK + } + , + { + 0, 0, 0 } } ; diff --git a/parser.h b/parser.h index 2fccf9750..b7c3ea684 100644 --- a/parser.h +++ b/parser.h @@ -138,6 +138,7 @@ enum block_type BEGIN, /**< Unconditional block */ SOURCE, /**< Block created by the . (source) builtin */ EVENT, /**< Block created on event notifier invocation */ + BREAKPOINT, /**< Breakpoint block */ } ; diff --git a/reader.c b/reader.c index b76a9972e..c7fb7709f 100644 --- a/reader.c +++ b/reader.c @@ -1983,6 +1983,19 @@ static int read_i() { job_t *j; int has_job=0; + int is_breakpoint=0; + block_t *b; + + for( b = current_block; + b; + b = b->outer ) + { + if( b->type == BREAKPOINT ) + { + is_breakpoint = 1; + break; + } + } for( j=first_job; j; j=j->next ) { @@ -1992,8 +2005,8 @@ static int read_i() break; } } - - if( !reader_exit_forced() && !data->prev_end_loop && has_job ) + + if( !reader_exit_forced() && !data->prev_end_loop && has_job && !is_breakpoint ) { writestr(_( L"There are stopped jobs\n" ));