summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 1397409..a0f190f 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1343,8 +1343,10 @@ int read_line_input(const char *prompt, char *command, int maxsize, line_input_t
int len;
parse_and_put_prompt(prompt);
fflush(stdout);
- fgets(command, maxsize, stdin);
- len = strlen(command);
+ if (fgets(command, maxsize, stdin) == NULL)
+ len = -1; /* EOF or error */
+ else
+ len = strlen(command);
DEINIT_S();
return len;
}