diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2022-03-03 19:19:35 +0000 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2022-03-03 19:19:35 +0000 |
commit | 1640457f4755a4a5248f5e9c0106fa01f8f1e9ff (patch) | |
tree | 17e020e967e53bd2dd04c9a1604dede4a6eb2064 /Src/input.c | |
parent | 2be2efc122b70a84a9debeaf0a11b99e11df3758 (diff) | |
download | zsh-1640457f4755a4a5248f5e9c0106fa01f8f1e9ff.tar.gz zsh-1640457f4755a4a5248f5e9c0106fa01f8f1e9ff.tar.xz zsh-1640457f4755a4a5248f5e9c0106fa01f8f1e9ff.zip |
49792: Non-interative shell input is line buffered.
Diffstat (limited to 'Src/input.c')
-rw-r--r-- | Src/input.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Src/input.c b/Src/input.c index caeaff0e3..c59232681 100644 --- a/Src/input.c +++ b/Src/input.c @@ -223,13 +223,20 @@ shingetchar(void) return STOUC(*shinbufptr++); shinbufreset(); - do { - errno = 0; - nread = read(SHIN, shinbuffer, SHINBUFSIZE); - } while (nread < 0 && errno == EINTR); - if (nread <= 0) - return -1; - shinbufendptr = shinbuffer + nread; + for (;;) { + errno = 0; + nread = read(SHIN, shinbufendptr, 1); + if (nread > 0) { + /* Use line buffering (POSIX requirement) */ + if (*shinbufendptr++ == '\n') + break; + if (shinbufendptr == shinbuffer + SHINBUFSIZE) + break; + } else if (nread == 0 || errno != EINTR) + break; + } + if (shinbufendptr == shinbuffer) + return -1; return STOUC(*shinbufptr++); } |