From 0d5681866483177bc2a60a9aae45cf763c1bdba3 Mon Sep 17 00:00:00 2001 From: axel Date: Sat, 11 Mar 2006 05:51:00 +1000 Subject: [PATCH] Fix bad return status in read builtin darcs-hash:20060310195100-ac50b-2b7d94510661d901fd804074e6cf03e926dddc79.gz --- builtin.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/builtin.c b/builtin.c index a55281210..bf6b81bee 100644 --- a/builtin.c +++ b/builtin.c @@ -1347,7 +1347,8 @@ static int builtin_read( wchar_t **argv ) wchar_t *nxt; wchar_t *prompt = DEFAULT_READ_PROMPT; wchar_t *commandline = L""; - + int exit_res=0; + woptind=0; while( 1 ) @@ -1529,10 +1530,12 @@ static int builtin_read( wchar_t **argv ) else { string_buffer_t sb; + int eof=0; + sb_init( &sb ); + while( 1 ) { - int eof=0; int finished=0; wchar_t res=0; @@ -1573,11 +1576,18 @@ static int builtin_read( wchar_t **argv ) if( eof ) break; + if( res == L'\n' ) break; sb_append_char( &sb, res ); } + + if( sb.used < 2 && eof ) + { + exit_res = 1; + } + buff = wcsdup( (wchar_t *)sb.buff ); sb_destroy( &sb ); } @@ -1596,7 +1606,7 @@ static int builtin_read( wchar_t **argv ) } free( buff ); - return 0; + return exit_res; } /**