From aee076a26e4909c49baa4420b7bc4412d9ab6b5a Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 9 Feb 2023 23:09:31 +0100 Subject: read exit on error --- core/read.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core/read.c') diff --git a/core/read.c b/core/read.c index 82b74be..017fd3c 100644 --- a/core/read.c +++ b/core/read.c @@ -1,6 +1,7 @@ #include "../lib/io/io.h" #include "../lib/arg/arg.h" #include "../lib/list/list.h" +#include "../lib/sys/errno.h" #define BUF_SIZE 1024 @@ -89,6 +90,11 @@ int main(int argc, const char **argv) else fd = STDIN_FD; + if (fd < 0) { + wff(STDERR_FD, "read: %s\n", errstr[-fd]); + return -1; + } + mode_funcs[mode](fd); } -- cgit v1.2.3-70-g09d2