From 15e0a44fc7e5e2a0061db11eaac9edd947d131f3 Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 1 Feb 2007 09:58:10 +1000 Subject: [PATCH] Fix bug where pressing ^C while in the read builtin would mess up the block execution bit darcs-hash:20070131235810-ac50b-23dde9d0e13cc028b744307073c1daf989258b54.gz --- reader.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/reader.c b/reader.c index 50d4d4de1..1a1886ac1 100644 --- a/reader.c +++ b/reader.c @@ -256,6 +256,12 @@ typedef struct reader_data */ static reader_data_t *data=0; +/** + This flag is set to true when fish is interactively reading from + stdin. It changes how a ^C is handled by the fish interrupt + handler. +*/ +static int is_interactive_read; /** Flag for ending non-interactive shell @@ -400,11 +406,17 @@ static void reader_kill( wchar_t *begin, int length, int mode, int new ) void reader_handle_int( int sig ) { block_t *c = current_block; - while( c ) + + if( !is_interactive_read ) { - c->skip=1; - c=c->outer; + while( c ) + { + c->type=FAKE; + c->skip=1; + c=c->outer; + } } + interrupted = 1; } @@ -2077,9 +2089,11 @@ wchar_t *reader_readline() */ while( 1 ) { + int was_interactive_read = is_interactive_read; + is_interactive_read = 1; c=input_readch(); - - + is_interactive_read = was_interactive_read; + if( ( (!wchar_private(c))) && (c>31) && (c != 127) ) { if( can_read(0) )