From: Denis Vlasenko Date: Sat, 2 Feb 2008 18:50:50 +0000 (-0000) Subject: msh: also handle EOF/read errors correctly X-Git-Tag: 1_10_0~231 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6e602c49316bf75376467c1aeb194741e85421d4;p=oweals%2Fbusybox.git msh: also handle EOF/read errors correctly --- diff --git a/shell/msh.c b/shell/msh.c index 9a1be36d9..531ae779a 100644 --- a/shell/msh.c +++ b/shell/msh.c @@ -4836,11 +4836,11 @@ static int filechar(struct ioarg *ap) static int position = 0, size = 0; while (size == 0 || position >= size) { - /* Repeat if Ctrl-C is pressed. TODO: exit on -1 (error/EOF)? */ - while (read_line_input(current_prompt, filechar_cmdbuf, BUFSIZ, line_input_state) == 0) - continue; - size = strlen(filechar_cmdbuf); + size = read_line_input(current_prompt, filechar_cmdbuf, BUFSIZ, line_input_state); + if (size < 0) /* Error/EOF */ + exit(0); position = 0; + /* if Ctrl-C, size == 0 and loop will repeat */ } c = filechar_cmdbuf[position]; position++;