From d8811fb0200792abc363d9e0ff1ceea44617ec71 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 4 Sep 2015 20:19:40 -0700 Subject: linenoise: tty read fix. * linenoise/linenoise.c (edit): If 0 bytes is read from the tty for any reason, return -1 so that the linenoise function will return a null pointer rather than a blank line. --- linenoise/linenoise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index bdffcfff..3d596bd9 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -760,7 +760,8 @@ static int edit(int stdin_fd, int stdout_fd, char *buf, size_t buflen, const cha char seq[3]; nread = read(l.ifd,&c,1); - if (nread <= 0) return l.len; + if (nread <= 0) + return l.len ? l.len : -1; /* Only autocomplete when the callback is set. It returns < 0 when * there was an error reading from fd. Otherwise it will return the -- cgit v1.2.3