From c5ad54a55123582b09f9d9d8046623916c2dec4a Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 14 Jul 2022 17:23:50 +0200 Subject: user/shell/cat: support reading from stdin until eof --- src/user/driver/termcook.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/user/driver/termcook.c') diff --git a/src/user/driver/termcook.c b/src/user/driver/termcook.c index 6ed8223..56ac77c 100644 --- a/src/user/driver/termcook.c +++ b/src/user/driver/termcook.c @@ -28,8 +28,12 @@ static void line_editor(handle_t input, handle_t output) { } break; case 4: /* EOT, C-d */ - w_output(output, linebuf, linepos); - linepos = 0; + if (linepos > 0) { + w_output(output, linebuf, linepos); + linepos = 0; + } else { + _syscall_write(output, NULL, 0, 0); // eof + } break; case '\n': case '\r': -- cgit v1.2.3