From 5a7a264b961210579222febe680e09cf0f39a08b Mon Sep 17 00:00:00 2001 From: axel Date: Mon, 15 May 2006 08:29:05 +1000 Subject: [PATCH] Fix bug that caused block level io redirection to break on while loops darcs-hash:20060514222905-ac50b-7dec0ed716f5fe6af9069b597eee464829a8d820.gz --- builtin.c | 2 +- exec.c | 7 ++++--- io.c | 17 +++++++---------- io.h | 2 ++ parser.c | 4 +++- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/builtin.c b/builtin.c index ed4ecc67f..e5b76ac33 100644 --- a/builtin.c +++ b/builtin.c @@ -1334,7 +1334,7 @@ static int builtin_read( wchar_t **argv ) int exit_res=0; woptind=0; - + while( 1 ) { const static struct woption diff --git a/exec.c b/exec.c index 949a97703..455af2697 100644 --- a/exec.c +++ b/exec.c @@ -564,7 +564,7 @@ static void internal_exec_helper( const wchar_t *def, io_data_t *io_internal = io_transmogrify( io ); int is_block_old=is_block; is_block=1; - + /* Did the transmogrification fail - if so, set error status and return */ @@ -575,7 +575,7 @@ static void internal_exec_helper( const wchar_t *def, } signal_unblock(); - + eval( def, io_internal, block_type ); signal_block(); @@ -837,7 +837,7 @@ void exec( job_t *j ) io_buffer = io_buffer_create(); j->io = io_add( j->io, io_buffer ); } - + internal_exec_helper( p->argv[0], TOP, j->io ); break; @@ -852,6 +852,7 @@ void exec( job_t *j ) if( p == j->first_process ) { io_data_t *in = io_get( j->io, 0 ); + if( in ) { switch( in->io_mode ) diff --git a/io.c b/io.c index 7d515b2ed..608a3090b 100644 --- a/io.c +++ b/io.c @@ -213,37 +213,34 @@ io_data_t *io_get( io_data_t *io, int fd ) return 0; } -/* -static void io_print( io_data_t *io ) + +void io_print( io_data_t *io ) { if( !io ) { - fwprintf( stderr, L"\n" ); return; } - - fwprintf( stderr, L"IO fd %d, type ", + debug( 1, L"IO fd %d, type ", io->fd ); switch( io->io_mode ) { case IO_PIPE: - fwprintf(stderr, L"PIPE, data %d\n", io->pipe_fd[io->fd?1:0] ); + debug( 1, L"PIPE, data %d", io->param1.pipe_fd[io->fd?1:0] ); break; case IO_FD: - fwprintf(stderr, L"FD, copy %d\n", io->old_fd ); + debug( 1, L"FD, copy %d", io->param1.old_fd ); break; case IO_BUFFER: - fwprintf( stderr, L"BUFFER\n" ); + debug( 1, L"BUFFER" ); break; default: - fwprintf( stderr, L"OTHER\n" ); + debug( 1, L"OTHER" ); } io_print( io->next ); } -*/ diff --git a/io.h b/io.h index d52211dfc..70a925ba1 100644 --- a/io.h +++ b/io.h @@ -89,4 +89,6 @@ io_data_t *io_buffer_create(); */ void io_buffer_read( io_data_t *d ); +void io_print( io_data_t *io ); + #endif diff --git a/parser.c b/parser.c index 20bbe6dfa..d35c9a588 100644 --- a/parser.c +++ b/parser.c @@ -1878,6 +1878,7 @@ static int parse_job( process_t *p, consumed=1; is_new_block=1; + } else if( wcscmp( L"if", nxt ) ==0 ) { @@ -1937,7 +1938,7 @@ static int parse_job( process_t *p, builtin_exists( (wchar_t *)al_get( args, 0 ) ) ) { p->type = INTERNAL_BUILTIN; - is_new_block = parser_is_block( (wchar_t *)al_get( args, 0 ) ); + is_new_block |= parser_is_block( (wchar_t *)al_get( args, 0 ) ); } } @@ -2075,6 +2076,7 @@ static int parse_job( process_t *p, if( !make_sub_block ) { + tok_init( &subtok, end, 0 ); switch( tok_last_type( &subtok ) ) {