Fix bug where pressing ^C while in the read builtin would mess up the block execution bit

darcs-hash:20070131235810-ac50b-23dde9d0e13cc028b744307073c1daf989258b54.gz
This commit is contained in:
axel 2007-02-01 09:58:10 +10:00
parent 3b653cd26a
commit 15e0a44fc7

View File

@ -256,6 +256,12 @@ typedef struct reader_data
*/ */
static reader_data_t *data=0; 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 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 ) void reader_handle_int( int sig )
{ {
block_t *c = current_block; block_t *c = current_block;
if( !is_interactive_read )
{
while( c ) while( c )
{ {
c->type=FAKE;
c->skip=1; c->skip=1;
c=c->outer; c=c->outer;
} }
}
interrupted = 1; interrupted = 1;
} }
@ -2077,8 +2089,10 @@ wchar_t *reader_readline()
*/ */
while( 1 ) while( 1 )
{ {
int was_interactive_read = is_interactive_read;
is_interactive_read = 1;
c=input_readch(); c=input_readch();
is_interactive_read = was_interactive_read;
if( ( (!wchar_private(c))) && (c>31) && (c != 127) ) if( ( (!wchar_private(c))) && (c>31) && (c != 127) )
{ {