summaryrefslogtreecommitdiff
path: root/src/user/driver
diff options
context:
space:
mode:
authordzwdz2022-07-14 17:23:50 +0200
committerdzwdz2022-07-14 17:23:50 +0200
commitc5ad54a55123582b09f9d9d8046623916c2dec4a (patch)
tree0945ecd0d2fbd454504fa15ee5f5db76b2194785 /src/user/driver
parent22a3e004cdf41cb3a48d9087f8bf87e56cc4cbe9 (diff)
user/shell/cat: support reading from stdin until eof
Diffstat (limited to 'src/user/driver')
-rw-r--r--src/user/driver/termcook.c8
1 files changed, 6 insertions, 2 deletions
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':