diff options
author | axel <axel@liljencrantz.se> | 2006-03-11 05:51:00 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-03-11 05:51:00 +1000 |
commit | 0d5681866483177bc2a60a9aae45cf763c1bdba3 (patch) | |
tree | a5d08e0eec476b36042baf81c56235141e9a1bb1 /builtin.c | |
parent | 5b0cd5a911cf6755e19b454e5fdb8eb47f688529 (diff) |
Fix bad return status in read builtin
darcs-hash:20060310195100-ac50b-2b7d94510661d901fd804074e6cf03e926dddc79.gz
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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; } /** |