commit 757a657ed0eeea667839cd65d46a3f41b19b4ddc
parent 20f5abcdc25663213924830693966b6df2748d8a
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Wed, 23 Dec 2020 18:12:11 -0800
Check the fatal flag in the main loop and fix EOF
Diffstat:
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/main.c b/main.c
@@ -639,7 +639,7 @@ gawk(const char **addr)
mycache = 1;
if (gph_write(addr, cache) == 1)
return 0; /* let the user handle it */
- run_filters(cache, NULL, 0, NULL, cprintn);
+ done = run_filters(cache, NULL, 0, NULL, cprintn);
}
/* NOTE: do not return until --depth */
@@ -647,7 +647,7 @@ gawk(const char **addr)
done = 0;
snprintf(prompt, sizeof(prompt), "(%d) [%s] %s ", depth, addr[AR_HOST], addr[AR_PATH]);
- while (!done && input(inbuf, sizeof(inbuf), ISS, prompt, stdin) == 0) {
+ while (!fatal && !done && input(inbuf, sizeof(inbuf), ISS, prompt, stdin) == 0) {
argc = argsplit(argv, LEN(argv), inbuf, IFS);
if (argc < 0) {
warnx("Too many arguments.");
@@ -660,15 +660,14 @@ gawk(const char **addr)
if (mycache && unlink(cache) == -1)
warn("unable to unlink '%s'", cache);
- if (feof(stdin)) {
+ if (feof(stdin))
done = depth;
- }
--depth;
if (ferror(stdin)) {
warn("'%s'", "/dev/stdin");
- return -1;
+ return fatal = -1;
}
return done - 1;
}